Validate workflow rule writes

This commit is contained in:
2026-06-02 10:22:15 +02:00
parent e9825f5bf5
commit a3bad1bdd4
7 changed files with 419 additions and 75 deletions
@@ -120,7 +120,7 @@ public sealed class WorkflowRulesEditorTools
var updated = replace_file
? yaml
: AgentFileToolContent.AppendContent(existing, yaml);
var validation = ValidateYaml(updated);
var validation = await ValidateYamlAsync(updated);
if (validation is not null)
{
return validation;
@@ -930,22 +930,27 @@ public sealed class WorkflowRulesEditorTools
}
}
private static string? ValidateYaml(string yaml)
private static async Task<string?> ValidateYamlAsync(string yaml)
{
if (string.IsNullOrWhiteSpace(yaml))
{
return null;
}
MeetingWorkflowRulesFile rulesFile;
try
{
_ = YamlDeserializer.Deserialize<MeetingWorkflowRulesFile>(yaml);
return null;
rulesFile = YamlDeserializer.Deserialize<MeetingWorkflowRulesFile>(yaml) ?? new MeetingWorkflowRulesFile();
}
catch (YamlException exception)
{
return $"Refused: workflow rules YAML is invalid. {exception.Message}";
}
var errors = await MeetingWorkflowRulesValidator.ValidateAsync(rulesFile);
return errors.Count == 0
? null
: "Refused: workflow rules are invalid. " + string.Join(" ", errors);
}
private async Task WriteRecommendedProjectSeedAsync(string projectRoot, string projectName)