From 7b0989df137bc87ac74a49eb82f77f269fcab7cb Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 22 Feb 2026 05:05:01 +0000 Subject: [PATCH 1/2] Initial plan From 4e8e5a23e6fa60125e0df7c7b212b967b4e58697 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 22 Feb 2026 05:27:15 +0000 Subject: [PATCH 2/2] feat: qualify default repo-memory branch by workflow ID When repo-memory is configured without an explicit branch-name, the default branch is now memory/{workflow-id} instead of memory/default. For example, a workflow named repo-assist.md uses memory/repo-assist. Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com> --- .github/workflows/daily-code-metrics.lock.yml | 6 ++-- .../compiler_orchestrator_workflow.go | 2 +- pkg/workflow/repo_memory.go | 31 ++++++++++++++----- pkg/workflow/repo_memory_test.go | 30 +++++++++--------- 4 files changed, 43 insertions(+), 26 deletions(-) diff --git a/.github/workflows/daily-code-metrics.lock.yml b/.github/workflows/daily-code-metrics.lock.yml index 568dc86cb7..c33f7858bc 100644 --- a/.github/workflows/daily-code-metrics.lock.yml +++ b/.github/workflows/daily-code-metrics.lock.yml @@ -237,7 +237,7 @@ jobs: GH_AW_GITHUB_REPOSITORY: ${{ github.repository }} GH_AW_GITHUB_RUN_ID: ${{ github.run_id }} GH_AW_GITHUB_WORKSPACE: ${{ github.workspace }} - GH_AW_MEMORY_BRANCH_NAME: 'daily/default' + GH_AW_MEMORY_BRANCH_NAME: 'daily/daily-code-metrics' GH_AW_MEMORY_CONSTRAINTS: ' **Constraints:** @@ -374,7 +374,7 @@ jobs: env: GH_TOKEN: ${{ github.token }} GITHUB_SERVER_URL: ${{ github.server_url }} - BRANCH_NAME: daily/default + BRANCH_NAME: daily/daily-code-metrics TARGET_REPO: ${{ github.repository }} MEMORY_DIR: /tmp/gh-aw/repo-memory/default CREATE_ORPHAN: true @@ -1323,7 +1323,7 @@ jobs: ARTIFACT_DIR: /tmp/gh-aw/repo-memory/default MEMORY_ID: default TARGET_REPO: ${{ github.repository }} - BRANCH_NAME: daily/default + BRANCH_NAME: daily/daily-code-metrics MAX_FILE_SIZE: 102400 MAX_FILE_COUNT: 100 ALLOWED_EXTENSIONS: '[]' diff --git a/pkg/workflow/compiler_orchestrator_workflow.go b/pkg/workflow/compiler_orchestrator_workflow.go index f5dcdb0383..c705bfe6a5 100644 --- a/pkg/workflow/compiler_orchestrator_workflow.go +++ b/pkg/workflow/compiler_orchestrator_workflow.go @@ -449,7 +449,7 @@ func (c *Compiler) extractAdditionalConfigurations( if err != nil { return err } - repoMemoryConfig, err := c.extractRepoMemoryConfig(toolsConfig) + repoMemoryConfig, err := c.extractRepoMemoryConfig(toolsConfig, workflowData.WorkflowID) if err != nil { return err } diff --git a/pkg/workflow/repo_memory.go b/pkg/workflow/repo_memory.go index f0d875a6f9..639b8b0c9a 100644 --- a/pkg/workflow/repo_memory.go +++ b/pkg/workflow/repo_memory.go @@ -96,8 +96,9 @@ func validateBranchPrefix(prefix string) error { return nil } -// extractRepoMemoryConfig extracts repo-memory configuration from tools section -func (c *Compiler) extractRepoMemoryConfig(toolsConfig *ToolsConfig) (*RepoMemoryConfig, error) { +// extractRepoMemoryConfig extracts repo-memory configuration from tools section. +// workflowID is used to qualify the default branch name (e.g. "memory/{workflowID}"). +func (c *Compiler) extractRepoMemoryConfig(toolsConfig *ToolsConfig, workflowID string) (*RepoMemoryConfig, error) { // Check if repo-memory tool is configured if toolsConfig == nil || toolsConfig.RepoMemory == nil { return nil, nil @@ -110,13 +111,22 @@ func (c *Compiler) extractRepoMemoryConfig(toolsConfig *ToolsConfig) (*RepoMemor } repoMemoryValue := toolsConfig.RepoMemory.Raw + // defaultMemoryBranchID returns workflowID when set, otherwise "default". + // This qualifies the default branch name by workflow, e.g. "memory/repo-assist". + defaultMemoryBranchID := func() string { + if workflowID != "" { + return workflowID + } + return "default" + } + // Handle nil value (simple enable with defaults) - same as true if repoMemoryValue == nil { repoMemoryLog.Print("Using default repo-memory configuration (nil value)") config.Memories = []RepoMemoryEntry{ { ID: "default", - BranchName: generateDefaultBranchName("default", config.BranchPrefix), + BranchName: generateDefaultBranchName(defaultMemoryBranchID(), config.BranchPrefix), MaxFileSize: 10240, // 10KB MaxFileCount: 100, CreateOrphan: true, @@ -134,7 +144,7 @@ func (c *Compiler) extractRepoMemoryConfig(toolsConfig *ToolsConfig) (*RepoMemor config.Memories = []RepoMemoryEntry{ { ID: "default", - BranchName: generateDefaultBranchName("default", config.BranchPrefix), + BranchName: generateDefaultBranchName(defaultMemoryBranchID(), config.BranchPrefix), MaxFileSize: 10240, // 10KB MaxFileCount: 100, CreateOrphan: true, @@ -178,9 +188,11 @@ func (c *Compiler) extractRepoMemoryConfig(toolsConfig *ToolsConfig) (*RepoMemor } // ID is required for array notation + explicitID := false if id, exists := memoryMap["id"]; exists { if idStr, ok := id.(string); ok { entry.ID = idStr + explicitID = true } } // Use "default" if no ID specified @@ -201,9 +213,14 @@ func (c *Compiler) extractRepoMemoryConfig(toolsConfig *ToolsConfig) (*RepoMemor entry.BranchName = branchStr } } - // Set default branch name if not specified + // Set default branch name if not specified. + // When no explicit ID was provided (defaulted to "default"), qualify the branch by workflow ID. if entry.BranchName == "" { - entry.BranchName = generateDefaultBranchName(entry.ID, config.BranchPrefix) + branchID := entry.ID + if !explicitID { + branchID = defaultMemoryBranchID() + } + entry.BranchName = generateDefaultBranchName(branchID, config.BranchPrefix) } // Parse file-glob @@ -311,7 +328,7 @@ func (c *Compiler) extractRepoMemoryConfig(toolsConfig *ToolsConfig) (*RepoMemor entry := RepoMemoryEntry{ ID: "default", - BranchName: generateDefaultBranchName("default", config.BranchPrefix), + BranchName: generateDefaultBranchName(defaultMemoryBranchID(), config.BranchPrefix), MaxFileSize: 10240, // 10KB default MaxFileCount: 100, // 100 files default CreateOrphan: true, // create orphan by default diff --git a/pkg/workflow/repo_memory_test.go b/pkg/workflow/repo_memory_test.go index 5007cf84cc..9b249c43fe 100644 --- a/pkg/workflow/repo_memory_test.go +++ b/pkg/workflow/repo_memory_test.go @@ -22,7 +22,7 @@ func TestRepoMemoryConfigDefault(t *testing.T) { } compiler := NewCompiler() - config, err := compiler.extractRepoMemoryConfig(toolsConfig) + config, err := compiler.extractRepoMemoryConfig(toolsConfig, "my-workflow") if err != nil { t.Fatalf("Failed to extract repo-memory config: %v", err) } @@ -40,8 +40,8 @@ func TestRepoMemoryConfigDefault(t *testing.T) { t.Errorf("Expected ID 'default', got '%s'", memory.ID) } - if memory.BranchName != "memory/default" { - t.Errorf("Expected branch name 'memory/default', got '%s'", memory.BranchName) + if memory.BranchName != "memory/my-workflow" { + t.Errorf("Expected branch name 'memory/my-workflow', got '%s'", memory.BranchName) } if memory.MaxFileSize != 10240 { @@ -74,7 +74,7 @@ func TestRepoMemoryConfigObject(t *testing.T) { } compiler := NewCompiler() - config, err := compiler.extractRepoMemoryConfig(toolsConfig) + config, err := compiler.extractRepoMemoryConfig(toolsConfig, "") if err != nil { t.Fatalf("Failed to extract repo-memory config: %v", err) } @@ -127,7 +127,7 @@ func TestRepoMemoryConfigArray(t *testing.T) { } compiler := NewCompiler() - config, err := compiler.extractRepoMemoryConfig(toolsConfig) + config, err := compiler.extractRepoMemoryConfig(toolsConfig, "") if err != nil { t.Fatalf("Failed to extract repo-memory config: %v", err) } @@ -183,7 +183,7 @@ func TestRepoMemoryConfigDuplicateIDs(t *testing.T) { } compiler := NewCompiler() - _, err = compiler.extractRepoMemoryConfig(toolsConfig) + _, err = compiler.extractRepoMemoryConfig(toolsConfig, "") if err == nil { t.Fatal("Expected error for duplicate memory IDs, got nil") } @@ -395,7 +395,7 @@ func TestRepoMemoryMaxFileSizeValidation(t *testing.T) { } compiler := NewCompiler() - config, err := compiler.extractRepoMemoryConfig(toolsConfig) + config, err := compiler.extractRepoMemoryConfig(toolsConfig, "") if tt.wantError { if err == nil { @@ -465,7 +465,7 @@ func TestRepoMemoryMaxFileSizeValidationArray(t *testing.T) { } compiler := NewCompiler() - config, err := compiler.extractRepoMemoryConfig(toolsConfig) + config, err := compiler.extractRepoMemoryConfig(toolsConfig, "") if tt.wantError { if err == nil { @@ -554,7 +554,7 @@ func TestRepoMemoryMaxFileCountValidation(t *testing.T) { } compiler := NewCompiler() - config, err := compiler.extractRepoMemoryConfig(toolsConfig) + config, err := compiler.extractRepoMemoryConfig(toolsConfig, "") if tt.wantError { if err == nil { @@ -624,7 +624,7 @@ func TestRepoMemoryMaxFileCountValidationArray(t *testing.T) { } compiler := NewCompiler() - config, err := compiler.extractRepoMemoryConfig(toolsConfig) + config, err := compiler.extractRepoMemoryConfig(toolsConfig, "") if tt.wantError { if err == nil { @@ -778,7 +778,7 @@ func TestBranchPrefixInConfig(t *testing.T) { require.NoError(t, err, "Failed to parse tools config") compiler := NewCompiler() - config, err := compiler.extractRepoMemoryConfig(toolsConfig) + config, err := compiler.extractRepoMemoryConfig(toolsConfig, "my-workflow") require.NoError(t, err, "Failed to extract repo-memory config") require.NotNil(t, config, "Expected non-nil config") @@ -786,7 +786,7 @@ func TestBranchPrefixInConfig(t *testing.T) { assert.Len(t, config.Memories, 1, "Expected 1 memory") memory := config.Memories[0] - assert.Equal(t, "campaigns/default", memory.BranchName, "Expected branch name 'campaigns/default'") + assert.Equal(t, "campaigns/my-workflow", memory.BranchName, "Expected branch name 'campaigns/my-workflow'") } // TestBranchPrefixInArrayConfig tests branch-prefix in array configuration @@ -807,7 +807,7 @@ func TestBranchPrefixInArrayConfig(t *testing.T) { require.NoError(t, err, "Failed to parse tools config") compiler := NewCompiler() - config, err := compiler.extractRepoMemoryConfig(toolsConfig) + config, err := compiler.extractRepoMemoryConfig(toolsConfig, "") require.NoError(t, err, "Failed to extract repo-memory config") require.NotNil(t, config, "Expected non-nil config") @@ -832,7 +832,7 @@ func TestBranchPrefixWithExplicitBranchName(t *testing.T) { require.NoError(t, err, "Failed to parse tools config") compiler := NewCompiler() - config, err := compiler.extractRepoMemoryConfig(toolsConfig) + config, err := compiler.extractRepoMemoryConfig(toolsConfig, "") require.NoError(t, err, "Failed to extract repo-memory config") require.NotNil(t, config, "Expected non-nil config") @@ -866,7 +866,7 @@ func TestInvalidBranchPrefixRejectsConfig(t *testing.T) { require.NoError(t, err, "Failed to parse tools config") compiler := NewCompiler() - config, err := compiler.extractRepoMemoryConfig(toolsConfig) + config, err := compiler.extractRepoMemoryConfig(toolsConfig, "") require.Error(t, err, "Expected error for invalid branch-prefix: %s", tt.prefix) assert.Nil(t, config, "Expected nil config on error") })