fix(worker): name quarantined prompt files and their replacements in the recovery Warn
PromptFileRecovery's orphan-quarantine log only reported a bare count, so a customized merge-helper-execute.md silently stopped applying with no pointer to where it went. Log each quarantined file's destination path, and for merge-helper-execute.md specifically call out that it was split into merge-helper-wait.md and merge-helper-merge.md with no content migration.
This commit is contained in:
@@ -24,10 +24,21 @@ public sealed class PromptFileRecovery : IHostedService
|
|||||||
PromptFiles.ReconcileStaleDefaults(_root);
|
PromptFiles.ReconcileStaleDefaults(_root);
|
||||||
|
|
||||||
var orphans = PromptFiles.QuarantineOrphans(_root);
|
var orphans = PromptFiles.QuarantineOrphans(_root);
|
||||||
if (orphans.Count > 0)
|
if (orphans.Count == 0)
|
||||||
_logger.LogWarning("Prompt file recovery: quarantined {Count} orphaned prompt file(s) into _orphans", orphans.Count);
|
{
|
||||||
else
|
|
||||||
_logger.LogInformation("Prompt file recovery: no orphaned prompt files found");
|
_logger.LogInformation("Prompt file recovery: no orphaned prompt files found");
|
||||||
|
return Task.CompletedTask;
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (var orphan_path in orphans)
|
||||||
|
{
|
||||||
|
_logger.LogWarning("Prompt file recovery: quarantined orphaned prompt file {orphan_path}", orphan_path);
|
||||||
|
if (Path.GetFileNameWithoutExtension(orphan_path)
|
||||||
|
.StartsWith("merge-helper-execute", StringComparison.OrdinalIgnoreCase))
|
||||||
|
_logger.LogWarning(
|
||||||
|
"Prompt file recovery: {orphan_path} was a customization of the retired merge-helper-execute.md prompt, which was split into merge-helper-wait.md and merge-helper-merge.md; its content was not migrated to either",
|
||||||
|
orphan_path);
|
||||||
|
}
|
||||||
|
|
||||||
return Task.CompletedTask;
|
return Task.CompletedTask;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,12 +1,31 @@
|
|||||||
using System.Text.Json;
|
using System.Text.Json;
|
||||||
using ClaudeDo.Data;
|
using ClaudeDo.Data;
|
||||||
using ClaudeDo.Worker.Lifecycle;
|
using ClaudeDo.Worker.Lifecycle;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
using Microsoft.Extensions.Logging.Abstractions;
|
using Microsoft.Extensions.Logging.Abstractions;
|
||||||
|
|
||||||
namespace ClaudeDo.Worker.Tests.Lifecycle;
|
namespace ClaudeDo.Worker.Tests.Lifecycle;
|
||||||
|
|
||||||
public sealed class PromptFileRecoveryTests
|
public sealed class PromptFileRecoveryTests
|
||||||
{
|
{
|
||||||
|
private sealed class CapturingLogger<T> : ILogger<T>
|
||||||
|
{
|
||||||
|
public List<string> Messages { get; } = new();
|
||||||
|
|
||||||
|
public IDisposable BeginScope<TState>(TState state) where TState : notnull => NullScope.Instance;
|
||||||
|
public bool IsEnabled(LogLevel logLevel) => true;
|
||||||
|
|
||||||
|
public void Log<TState>(LogLevel logLevel, EventId eventId, TState state, Exception? exception,
|
||||||
|
Func<TState, Exception?, string> formatter)
|
||||||
|
=> Messages.Add(formatter(state, exception));
|
||||||
|
|
||||||
|
private sealed class NullScope : IDisposable
|
||||||
|
{
|
||||||
|
public static readonly NullScope Instance = new();
|
||||||
|
public void Dispose() { }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public async Task StartAsync_ReconcilesStaleDefaultAndQuarantinesOrphan_WithoutTouchingRealEdit()
|
public async Task StartAsync_ReconcilesStaleDefaultAndQuarantinesOrphan_WithoutTouchingRealEdit()
|
||||||
{
|
{
|
||||||
@@ -46,4 +65,33 @@ public sealed class PromptFileRecoveryTests
|
|||||||
if (Directory.Exists(root)) Directory.Delete(root, recursive: true);
|
if (Directory.Exists(root)) Directory.Delete(root, recursive: true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public async Task StartAsync_QuarantinesOrphanedMergeHelperExecute_WarnNamesFileAndReplacements()
|
||||||
|
{
|
||||||
|
var root = Path.Combine(Path.GetTempPath(), $"claudedo_prompts_{Guid.NewGuid():N}");
|
||||||
|
try
|
||||||
|
{
|
||||||
|
Directory.CreateDirectory(root);
|
||||||
|
var orphanPath = Path.Combine(root, "merge-helper-execute.md");
|
||||||
|
File.WriteAllText(orphanPath, "my old customized triage+wait+merge prompt");
|
||||||
|
|
||||||
|
var logger = new CapturingLogger<PromptFileRecovery>();
|
||||||
|
var sut = new PromptFileRecovery(logger, root);
|
||||||
|
|
||||||
|
await sut.StartAsync(CancellationToken.None);
|
||||||
|
|
||||||
|
var dest = Path.Combine(root, "_orphans", "merge-helper-execute.md");
|
||||||
|
Assert.False(File.Exists(orphanPath));
|
||||||
|
Assert.True(File.Exists(dest));
|
||||||
|
|
||||||
|
Assert.Contains(logger.Messages, m => m.Contains("merge-helper-execute.md") && m.Contains(dest));
|
||||||
|
Assert.Contains(logger.Messages, m =>
|
||||||
|
m.Contains("merge-helper-wait.md") && m.Contains("merge-helper-merge.md"));
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
if (Directory.Exists(root)) Directory.Delete(root, recursive: true);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user