diff --git a/docs/src/content/docs/reference/repo-memory.md b/docs/src/content/docs/reference/repo-memory.md index d26dbe40f5d..a57f41f71e8 100644 --- a/docs/src/content/docs/reference/repo-memory.md +++ b/docs/src/content/docs/reference/repo-memory.md @@ -30,7 +30,7 @@ tools: file-glob: ["*.md", "*.json"] max-file-size: 1048576 # 1MB (default 10KB) max-file-count: 50 # default 100 - max-patch-size: 102400 # 100KB max (default 10KB) + max-patch-size: 1048576 # 1MB max (default 10KB) target-repo: "owner/repository" create-orphan: true # default allowed-extensions: [".json", ".txt", ".md"] # Restrict file types (default: empty/all files allowed) @@ -41,7 +41,7 @@ tools: **File Type Restrictions**: Use `allowed-extensions` to restrict which file types can be stored (default: empty/all files allowed). When specified, only files with listed extensions (e.g., `[".json", ".txt", ".md"]`) can be saved. Files with disallowed extensions will trigger validation failures. -**Patch Size Limit**: Use `max-patch-size` to limit the total size of changes in a single push (default: 10KB, max: 100KB). The total size of the git diff (all staged changes combined) must not exceed this value. If it does, the push is rejected with an error. Use this to prevent large unintentional memory updates. +**Patch Size Limit**: Use `max-patch-size` to limit the total size of changes in a single push (default: 10KB, max: 1MB). The total size of the git diff (all staged changes combined) must not exceed this value. If it does, the push is rejected with an error. Use this to prevent large unintentional memory updates. **Note**: File glob patterns are matched against the **relative file path** within the artifact directory, not the branch path. Use bare extension patterns like `*.json` or `*.md` — do **not** include the branch name (e.g. `memory/custom-agent-for-aw/*.json` is incorrect). diff --git a/pkg/parser/schemas/main_workflow_schema.json b/pkg/parser/schemas/main_workflow_schema.json index a1c1c607e4d..80f65ef0930 100644 --- a/pkg/parser/schemas/main_workflow_schema.json +++ b/pkg/parser/schemas/main_workflow_schema.json @@ -4553,8 +4553,8 @@ "max-patch-size": { "type": "integer", "minimum": 1, - "maximum": 102400, - "description": "Maximum total patch size in bytes (default: 10240 = 10KB, max: 102400 = 100KB). The total size of the git diff must not exceed this value." + "maximum": 1048576, + "description": "Maximum total patch size in bytes (default: 10240 = 10KB, max: 1048576 = 1MB). The total size of the git diff must not exceed this value." }, "description": { "type": "string", @@ -4644,8 +4644,8 @@ "max-patch-size": { "type": "integer", "minimum": 1, - "maximum": 102400, - "description": "Maximum total patch size in bytes (default: 10240 = 10KB, max: 102400 = 100KB). The total size of the git diff must not exceed this value." + "maximum": 1048576, + "description": "Maximum total patch size in bytes (default: 10240 = 10KB, max: 1048576 = 1MB). The total size of the git diff must not exceed this value." }, "description": { "type": "string", diff --git a/pkg/workflow/repo_memory.go b/pkg/workflow/repo_memory.go index d833f8b6c75..76fcd3734a8 100644 --- a/pkg/workflow/repo_memory.go +++ b/pkg/workflow/repo_memory.go @@ -25,8 +25,8 @@ var repoMemoryLog = logger.New("workflow:repo_memory") const ( // defaultRepoMemoryMaxPatchSize is the default maximum total patch size in bytes (10KB). defaultRepoMemoryMaxPatchSize = 10240 - // maxRepoMemoryPatchSize is the maximum allowed value for max-patch-size (100KB). - maxRepoMemoryPatchSize = 102400 + // maxRepoMemoryPatchSize is the maximum allowed value for max-patch-size (1MB). + maxRepoMemoryPatchSize = 1048576 ) // Pre-compiled regexes for performance (avoid recompilation in hot paths) @@ -49,7 +49,7 @@ type RepoMemoryEntry struct { FileGlob []string `yaml:"file-glob,omitempty"` // file glob patterns for allowed files MaxFileSize int `yaml:"max-file-size,omitempty"` // maximum size per file in bytes (default: 10KB) MaxFileCount int `yaml:"max-file-count,omitempty"` // maximum file count per commit (default: 100) - MaxPatchSize int `yaml:"max-patch-size,omitempty"` // maximum total patch size in bytes (default: 10KB, max: 100KB) + MaxPatchSize int `yaml:"max-patch-size,omitempty"` // maximum total patch size in bytes (default: 10KB, max: 1MB) Description string `yaml:"description,omitempty"` // optional description for this memory CreateOrphan bool `yaml:"create-orphan,omitempty"` // create orphaned branch if missing (default: true) AllowedExtensions []string `yaml:"allowed-extensions,omitempty"` // allowed file extensions (default: [".json", ".jsonl", ".txt", ".md", ".csv"]) diff --git a/pkg/workflow/repo_memory_test.go b/pkg/workflow/repo_memory_test.go index 335fd45e965..fa59e7017b5 100644 --- a/pkg/workflow/repo_memory_test.go +++ b/pkg/workflow/repo_memory_test.go @@ -701,7 +701,12 @@ func TestRepoMemoryMaxPatchSizeValidation(t *testing.T) { wantError: false, }, { - name: "valid maximum size (102400 bytes = 100KB)", + name: "valid maximum size (1048576 bytes = 1MB)", + maxPatchSize: 1048576, + wantError: false, + }, + { + name: "valid old maximum size (102400 bytes = 100KB)", maxPatchSize: 102400, wantError: false, }, @@ -715,23 +720,28 @@ func TestRepoMemoryMaxPatchSizeValidation(t *testing.T) { maxPatchSize: 51200, wantError: false, }, + { + name: "valid large size (512000 bytes = 500KB)", + maxPatchSize: 512000, + wantError: false, + }, { name: "invalid zero size", maxPatchSize: 0, wantError: true, - errorText: "max-patch-size must be between 1 and 102400, got 0", + errorText: "max-patch-size must be between 1 and 1048576, got 0", }, { name: "invalid negative size", maxPatchSize: -1, wantError: true, - errorText: "max-patch-size must be between 1 and 102400, got -1", + errorText: "max-patch-size must be between 1 and 1048576, got -1", }, { name: "invalid size exceeds maximum", - maxPatchSize: 102401, + maxPatchSize: 1048577, wantError: true, - errorText: "max-patch-size must be between 1 and 102400, got 102401", + errorText: "max-patch-size must be between 1 and 1048576, got 1048577", }, } @@ -777,17 +787,22 @@ func TestRepoMemoryMaxPatchSizeValidationArray(t *testing.T) { maxPatchSize: 10240, wantError: false, }, + { + name: "valid large size in array (500KB)", + maxPatchSize: 512000, + wantError: false, + }, { name: "invalid size in array (zero)", maxPatchSize: 0, wantError: true, - errorText: "max-patch-size must be between 1 and 102400, got 0", + errorText: "max-patch-size must be between 1 and 1048576, got 0", }, { name: "invalid size in array (exceeds max)", - maxPatchSize: 102401, + maxPatchSize: 1048577, wantError: true, - errorText: "max-patch-size must be between 1 and 102400, got 102401", + errorText: "max-patch-size must be between 1 and 1048576, got 1048577", }, } diff --git a/scratchpad/repo-memory.md b/scratchpad/repo-memory.md index 422b28c9fc7..5bff8a0f671 100644 --- a/scratchpad/repo-memory.md +++ b/scratchpad/repo-memory.md @@ -234,7 +234,7 @@ tools: # file-glob: string[] (default: all files) # max-file-size: int (default: 10240, max: 104857600) # max-file-count: int (default: 100, max: 1000) - # max-patch-size: int (default: 10240, max: 102400) + # max-patch-size: int (default: 10240, max: 1048576) # description: string (optional) # create-orphan: boolean (default: true) # campaign-id: string (optional) @@ -248,7 +248,7 @@ tools: # file-glob: string[] (default: all files) # max-file-size: int (default: 10240, max: 104857600) # max-file-count: int (default: 100, max: 1000) - # max-patch-size: int (default: 10240, max: 102400) + # max-patch-size: int (default: 10240, max: 1048576) # description: string (optional) # create-orphan: boolean (default: true) # campaign-id: string (optional) @@ -383,7 +383,7 @@ file-glob: The total size of all changes (git diff) in a single repo-memory push MUST not exceed the configured maximum patch size. - **Minimum**: 1 byte -- **Maximum**: 102400 bytes (100 KB) +- **Maximum**: 1048576 bytes (1 MB) - **Default**: 10240 bytes (10 KB) - **Configuration**: `max-patch-size` (in bytes) - Validated during config parsing (Go layer)