validateEngineInlineDefinition validates an inline engine definition parsed from engine.runtime + optional engine.provider in the workflow frontmatter. Returns an error if: - The required runtime.id field is missing - The runtime.id does not match a known runtime adapter
(config *EngineConfig)
| 228 | // - The required runtime.id field is missing |
| 229 | // - The runtime.id does not match a known runtime adapter |
| 230 | func (c *Compiler) validateEngineInlineDefinition(config *EngineConfig) error { |
| 231 | if !config.IsInlineDefinition { |
| 232 | return nil |
| 233 | } |
| 234 | |
| 235 | engineValidationLog.Printf("Validating inline engine definition: runtimeID=%s", config.ID) |
| 236 | |
| 237 | if config.ID == "" { |
| 238 | return fmt.Errorf("inline engine definition is missing required 'runtime.id' field.\n\nExample:\nengine:\n runtime:\n id: codex\n\nSee: %s", constants.DocsEnginesURL) |
| 239 | } |
| 240 | |
| 241 | // Validate that runtime.id maps to a known runtime adapter. |
| 242 | if !c.engineRegistry.IsValidEngine(config.ID) { |
| 243 | // Try prefix match for backward compatibility (e.g. "codex-experimental") |
| 244 | if matched, err := c.engineRegistry.GetEngineByPrefix(config.ID); err == nil { |
| 245 | engineValidationLog.Printf("Inline engine runtime.id %q matched via prefix to runtime %q", config.ID, matched.GetID()) |
| 246 | } else { |
| 247 | validEngines := c.engineRegistry.GetSupportedEngines() |
| 248 | suggestions := parser.FindClosestMatches(config.ID, validEngines, 1) |
| 249 | enginesStr := strings.Join(validEngines, ", ") |
| 250 | |
| 251 | errMsg := fmt.Sprintf("inline engine definition references unknown runtime.id: %s. Known runtime IDs are: %s.\n\nExample:\nengine:\n runtime:\n id: codex\n\nSee: %s", |
| 252 | config.ID, enginesStr, constants.DocsEnginesURL) |
| 253 | if len(suggestions) > 0 { |
| 254 | errMsg = fmt.Sprintf("inline engine definition references unknown runtime.id: %s. Known runtime IDs are: %s.\n\nDid you mean: %s?\n\nExample:\nengine:\n runtime:\n id: codex\n\nSee: %s", |
| 255 | config.ID, enginesStr, suggestions[0], constants.DocsEnginesURL) |
| 256 | } |
| 257 | return errors.New(errMsg) |
| 258 | } |
| 259 | } |
| 260 | |
| 261 | return nil |
| 262 | } |
| 263 | |
| 264 | // registerInlineEngineDefinition registers an inline engine definition in the session |
| 265 | // catalog. If the runtime ID already exists in the catalog (e.g. a built-in), the |