Self-hosted workflows for coding-agent delivery. Orchestrate CodeBuddy, Codex and Claude Code with scripts and human approval gates. Includes Local workflows for coding assistants.
JavaScript agent-orchestrationagentic-workflowai-agentsai-codingclaude-codecode-reviewcodebuddycodexcoding-agentscursordeveloper-toolshuman-on-the-loopllmmcpmulti-agentsdlcself-hostedsopworkflow-automationworkflow-engine
refactor(runtime): share checkpoint path exclusion check (#397)
fx-kurumi80664628cf3a
diff --git a/internal/runtime/workspace_checkpoint.go b/internal/runtime/workspace_checkpoint.goindex 80847bdf..6cf265e9 100644--- a/internal/runtime/workspace_checkpoint.go+++ b/internal/runtime/workspace_checkpoint.go@@ -9,6 +9,7 @@ import ("io/fs""os""path/filepath"+ "slices""strings")@@ -22,25 +23,32 @@ const WorkspaceCheckpointArchiveMaxBytes = 512 << 20const WorkspaceCheckpointChunkBytes = 4 << 20const workspaceCheckpointExpandedMax = 2 << 30-func checkpointExcluded(path string) bool {+// checkpointRestoreExcludedNames are path components a restored archive must+// never contain.+var checkpointRestoreExcludedNames = []string{".agentflow", "node_modules", ".cache", "__pycache__"}++// checkpointExcludedNames are skipped when capturing. Older valid archives can+// contain .zvec-grep, so it is excluded from new captures only and must not+// make those existing snapshots unrestorable.+var checkpointExcludedNames = append(slices.Clone(checkpointRestoreExcludedNames), ".zvec-grep")++func checkpointPathHasComponent(path string, names []string) bool {for _, part := range strings.Split(filepath.ToSlash(path), "/") {- if part == ".agentflow" || part == "node_modules" || part == ".cache" || part == "__pycache__" || part == ".zvec-grep" {+ if slices.Contains(names, part) {return true}}return false}-// Older valid archives can contain .zvec-grep. Excluding it from new captures-// must not make those existing snapshots unrestorable.+func checkpointExcluded(path string) bool {+ return checkpointPathHasComponent(path, checkpointExcludedNames)+}+func checkpointRestoreExcluded(path string) bool {- for _, part := range strings.Split(filepath.ToSlash(path), "/") {- if part == ".agentflow" || part == "node_modules" || part == ".cache" || part == "__pycache__" {- return true- }- }- return false+ return checkpointPathHasComponent(path, checkpointRestoreExcludedNames)}+func checkpointPath(path string) (string, error) {clean := filepath.Clean(filepath.FromSlash(path))if clean == "." || filepath.IsAbs(clean) || clean == ".." || strings.HasPrefix(clean, ".."+string(filepath.Separator)) {diff --git a/internal/runtime/workspace_checkpoint_excluded_test.go b/internal/runtime/workspace_checkpoint_excluded_test.gonew file mode 100644index 00000000..ab1c9b96--- /dev/null+++ b/internal/runtime/workspace_checkpoint_excluded_test.go@@ -0,0 +1,35 @@+package runtime++import "testing"++func TestCheckpointExclusionNames(t *testing.T) {+ cases := []struct {+ path string+ capture, restore bool+ }{+ {"src/main.go", false, false},+ {".agentflow", true, true},+ {"a/node_modules/x.js", true, true},+ {"pkg/.cache/blob", true, true},+ {"py/__pycache__/m.pyc", true, true},+ {".zvec-grep/index", true, false},+ {"deep/.zvec-grep", true, false},+ {".cache2/file", false, false},+ {"my_node_modules/a", false, false},+ {"docs/.agentflow.md", false, false},+ }+ for _, tc := range cases {+ if got := checkpointExcluded(tc.path); got != tc.capture {+ t.Errorf("checkpointExcluded(%q) = %v, want %v", tc.path, got, tc.capture)+ }+ if got := checkpointRestoreExcluded(tc.path); got != tc.restore {+ t.Errorf("checkpointRestoreExcluded(%q) = %v, want %v", tc.path, got, tc.restore)+ }+ }+}++func TestCheckpointExcludedNamesDoNotAliasRestoreNames(t *testing.T) {+ if len(checkpointRestoreExcludedNames) != 4 || len(checkpointExcludedNames) != 5 {+ t.Fatalf("unexpected exclusion lists: restore=%v capture=%v", checkpointRestoreExcludedNames, checkpointExcludedNames)+ }+}