-
Notifications
You must be signed in to change notification settings - Fork 263
refactor(workflow): Priority 1 semantic clustering — shared mount validation, copilot function relocation #17768
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
pelikhan
merged 3 commits into
main
from
copilot/refactor-semantic-function-clustering-6dcb86e4-d38e-4ade-8b9b-9856d4d1cd55
Feb 22, 2026
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,126 @@ | ||
| //go:build !integration | ||
|
|
||
| package workflow | ||
|
|
||
| import ( | ||
| "testing" | ||
|
|
||
| "github.com/stretchr/testify/assert" | ||
| "github.com/stretchr/testify/require" | ||
| ) | ||
|
|
||
| // TestValidateMCPMountsSyntax tests the MCP mount syntax validation function. | ||
| func TestValidateMCPMountsSyntax(t *testing.T) { | ||
| tests := []struct { | ||
| name string | ||
| toolName string | ||
| mountsRaw any | ||
| wantErr bool | ||
| errMsg string | ||
| }{ | ||
| { | ||
| name: "valid []string - ro mount", | ||
| toolName: "my-tool", | ||
| mountsRaw: []string{"/host/data:/data:ro"}, | ||
| wantErr: false, | ||
| }, | ||
| { | ||
| name: "valid []string - rw mount", | ||
| toolName: "my-tool", | ||
| mountsRaw: []string{"/host/data:/data:rw"}, | ||
| wantErr: false, | ||
| }, | ||
| { | ||
| name: "valid []any with string items", | ||
| toolName: "my-tool", | ||
| mountsRaw: []any{ | ||
| "/host/data:/data:ro", | ||
| "/usr/bin/tool:/usr/bin/tool:ro", | ||
| }, | ||
| wantErr: false, | ||
| }, | ||
| { | ||
| name: "empty []string", | ||
| toolName: "my-tool", | ||
| mountsRaw: []string{}, | ||
| wantErr: false, | ||
| }, | ||
| { | ||
| name: "invalid type — neither []any nor []string", | ||
| toolName: "my-tool", | ||
| mountsRaw: "not-an-array", | ||
| wantErr: true, | ||
| errMsg: "must be an array of strings", | ||
| }, | ||
| { | ||
| name: "invalid format — too few parts", | ||
| toolName: "my-tool", | ||
| mountsRaw: []string{"/host/path:/container/path"}, | ||
| wantErr: true, | ||
| errMsg: "must follow 'source:destination:mode' format", | ||
| }, | ||
| { | ||
| name: "invalid format — too many parts", | ||
| toolName: "my-tool", | ||
| mountsRaw: []string{"/host/path:/container/path:ro:extra"}, | ||
| wantErr: true, | ||
| errMsg: "must follow 'source:destination:mode' format", | ||
| }, | ||
| { | ||
| name: "invalid mode value", | ||
| toolName: "my-tool", | ||
| mountsRaw: []string{"/host/path:/container/path:invalid"}, | ||
| wantErr: true, | ||
| errMsg: "mode must be 'ro' or 'rw'", | ||
| }, | ||
| { | ||
| name: "invalid mode uppercase — case sensitive", | ||
| toolName: "my-tool", | ||
| mountsRaw: []string{"/host/path:/container/path:RO"}, | ||
| wantErr: true, | ||
| errMsg: "mode must be 'ro' or 'rw'", | ||
| }, | ||
| { | ||
| name: "error message includes tool name", | ||
| toolName: "special-tool", | ||
| mountsRaw: []string{"/host/path:/container/path"}, | ||
| wantErr: true, | ||
| errMsg: "special-tool", | ||
| }, | ||
| { | ||
| name: "error message includes mount index", | ||
| toolName: "my-tool", | ||
| mountsRaw: []string{ | ||
| "/host/data:/data:ro", | ||
| "/invalid/mount", | ||
| }, | ||
| wantErr: true, | ||
| errMsg: "mounts[1]", | ||
| }, | ||
| { | ||
| name: "[]any with non-string items are silently skipped", | ||
| toolName: "my-tool", | ||
| mountsRaw: []any{ | ||
| 123, // non-string, skipped | ||
| "/host/data:/data:ro", // valid string | ||
| }, | ||
| wantErr: false, | ||
| }, | ||
| } | ||
|
|
||
| for _, tt := range tests { | ||
| t.Run(tt.name, func(t *testing.T) { | ||
| err := validateMCPMountsSyntax(tt.toolName, tt.mountsRaw) | ||
|
|
||
| if tt.wantErr { | ||
| require.Error(t, err, "expected an error") | ||
| if tt.errMsg != "" { | ||
| assert.Contains(t, err.Error(), tt.errMsg, | ||
| "error message should contain %q", tt.errMsg) | ||
| } | ||
| } else { | ||
| assert.NoError(t, err) | ||
| } | ||
| }) | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The documentation comment is inaccurate. It states "Returns (source, dest, mode, nil) on success, or ("", "", "", error) on failure", but this doesn't describe the actual behavior correctly. The function returns empty strings for all values only when there's a format error (wrong number of parts), but returns the actual source, dest, and mode values when there's a mode validation error. The comment should be updated to clarify this distinction, for example: "Returns (source, dest, mode, nil) on success. On format errors (wrong number of parts), returns ("", "", "", error). On mode validation errors, returns (source, dest, invalid_mode, error) so callers can provide better error messages."