@@ -23,12 +23,24 @@ var mcpConfigSchema string
2323
2424// ValidateMainWorkflowFrontmatterWithSchema validates main workflow frontmatter using JSON schema
2525func ValidateMainWorkflowFrontmatterWithSchema (frontmatter map [string ]any ) error {
26- return validateWithSchema (frontmatter , mainWorkflowSchema , "main workflow file" )
26+ // First run the standard schema validation
27+ if err := validateWithSchema (frontmatter , mainWorkflowSchema , "main workflow file" ); err != nil {
28+ return err
29+ }
30+
31+ // Then run custom validation for engine-specific rules
32+ return validateEngineSpecificRules (frontmatter )
2733}
2834
2935// ValidateMainWorkflowFrontmatterWithSchemaAndLocation validates main workflow frontmatter with file location info
3036func ValidateMainWorkflowFrontmatterWithSchemaAndLocation (frontmatter map [string ]any , filePath string ) error {
31- return validateWithSchemaAndLocation (frontmatter , mainWorkflowSchema , "main workflow file" , filePath )
37+ // First run the standard schema validation with location
38+ if err := validateWithSchemaAndLocation (frontmatter , mainWorkflowSchema , "main workflow file" , filePath ); err != nil {
39+ return err
40+ }
41+
42+ // Then run custom validation for engine-specific rules
43+ return validateEngineSpecificRules (frontmatter )
3244}
3345
3446// ValidateIncludedFileFrontmatterWithSchema validates included file frontmatter using JSON schema
@@ -211,3 +223,40 @@ func min(a, b int) int {
211223 }
212224 return b
213225}
226+
227+ // validateEngineSpecificRules validates engine-specific rules that are not easily expressed in JSON schema
228+ func validateEngineSpecificRules (frontmatter map [string ]any ) error {
229+ // Check if engine is configured
230+ engine , ok := frontmatter ["engine" ]
231+ if ! ok {
232+ return nil // No engine specified, nothing to validate
233+ }
234+
235+ // Handle string format engine
236+ if engineStr , ok := engine .(string ); ok {
237+ // String format doesn't support permissions, so no validation needed
238+ _ = engineStr
239+ return nil
240+ }
241+
242+ // Handle object format engine
243+ engineMap , ok := engine .(map [string ]any )
244+ if ! ok {
245+ return nil // Invalid engine format, but this should be caught by schema validation
246+ }
247+
248+ // Check engine ID
249+ engineID , ok := engineMap ["id" ].(string )
250+ if ! ok {
251+ return nil // Missing or invalid ID, but this should be caught by schema validation
252+ }
253+
254+ // Check if codex engine has permissions configured
255+ if engineID == "codex" {
256+ if _ , hasPermissions := engineMap ["permissions" ]; hasPermissions {
257+ return errors .New ("Engine permissions are not supported for codex engine. Only Claude engine supports permissions configuration." )
258+ }
259+ }
260+
261+ return nil
262+ }
0 commit comments