Fix workflow rule validation logging
PR and Push Build/Test / build-and-test (push) Failing after 9m19s

This commit is contained in:
2026-06-03 17:33:12 +02:00
parent 40853115c5
commit 351ed2eb50
9 changed files with 243 additions and 102 deletions
@@ -9,6 +9,7 @@ using MeetingAssistant.Speakers;
using MeetingAssistant.Transcription;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Logging;
using YamlDotNet.Core;
using YamlDotNet.Serialization;
using YamlDotNet.Serialization.NamingConventions;
@@ -47,6 +48,7 @@ public sealed class WorkflowRulesEditorTools
private readonly ISpeakerIdentityMergeService? identityMergeService;
private readonly AsrDiagnosticService? asrDiagnosticService;
private readonly IConfiguration? configuration;
private readonly ILogger? logger;
public WorkflowRulesEditorTools(
MeetingAssistantOptions options,
@@ -62,7 +64,8 @@ public sealed class WorkflowRulesEditorTools
string? configDocsPath = null,
string? logDirectory = null,
string? specRootPath = null,
string? projectAgentsTemplatePath = null)
string? projectAgentsTemplatePath = null,
ILogger? logger = null)
{
this.options = options;
rulesPath = WorkflowRulesPathResolver.Resolve(options.Automation.RulesPath);
@@ -85,6 +88,7 @@ public sealed class WorkflowRulesEditorTools
this.identityMergeService = identityMergeService;
this.asrDiagnosticService = asrDiagnosticService;
this.configuration = configuration;
this.logger = logger;
}
public async Task<string> ReadRules(int? from = null, int? to = null, int? tail = null)
@@ -106,12 +110,12 @@ public sealed class WorkflowRulesEditorTools
{
if (rulesPath is null)
{
return "Refused: workflow rules file is not configured.";
return LogRefusal(nameof(WriteRules), "Refused: workflow rules file is not configured.");
}
if (yaml is null)
{
return "Refused: yaml must not be null.";
return LogRefusal(nameof(WriteRules), "Refused: yaml must not be null.");
}
var existing = File.Exists(rulesPath)
@@ -123,7 +127,7 @@ public sealed class WorkflowRulesEditorTools
var validation = await ValidateYamlAsync(updated);
if (validation is not null)
{
return validation;
return LogRefusal(nameof(WriteRules), validation);
}
Directory.CreateDirectory(Path.GetDirectoryName(rulesPath)!);
@@ -163,13 +167,13 @@ public sealed class WorkflowRulesEditorTools
{
if (json is null)
{
return "Refused: json must not be null.";
return LogRefusal(nameof(WriteConfig), "Refused: json must not be null.");
}
var validation = ValidateJson(json);
if (validation is not null)
{
return validation;
return LogRefusal(nameof(WriteConfig), validation);
}
Directory.CreateDirectory(Path.GetDirectoryName(configPath)!);
@@ -177,6 +181,15 @@ public sealed class WorkflowRulesEditorTools
return configPath;
}
private string LogRefusal(string toolName, string refusal)
{
logger?.LogWarning(
"Workflow rules editor tool {ToolName} refused request: {Refusal}",
toolName,
refusal);
return refusal;
}
public async Task<string> ReadConfigDocs(int? from = null, int? to = null, int? tail = null)
{
if (!File.Exists(configDocsPath))