fix(encyclopedia): tighten assign tests and first-paragraph handling

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-26 09:16:24 +01:00
co-authored by Claude Sonnet 5.5
parent e4384a2c54
commit a5322e71d2
3 changed files with 51 additions and 7 deletions
@@ -150,7 +150,12 @@ public sealed partial class AssignNotesUseCase(ITextModel model, EncyclopediaSet
log.LogWarning("Dropping new article {Slug}: empty scope", slug);
return null;
}
return new PlannedArticle(slug, Text(o["titleDe"]) ?? slug, Text(o["titleEn"]) ?? slug, category, scope, []);
if (Text(o["titleDe"]) is not { } titleDe || Text(o["titleEn"]) is not { } titleEn)
{
log.LogWarning("Dropping new article {Slug}: missing title", slug);
return null;
}
return new PlannedArticle(slug, titleDe, titleEn, category, scope, []);
}
private static string? Text(JsonNode? n) =>
@@ -177,8 +182,8 @@ public sealed partial class AssignNotesUseCase(ITextModel model, EncyclopediaSet
private static string FirstParagraph(string body)
{
var lines = body.Replace("\r", "").Split('\n')
.SkipWhile(l => l.Length == 0 || l.TrimStart().StartsWith('#'))
.TakeWhile(l => l.Trim().Length > 0);
.SkipWhile(l => string.IsNullOrWhiteSpace(l) || l.TrimStart().StartsWith('#'))
.TakeWhile(l => !string.IsNullOrWhiteSpace(l));
var text = Flatten(string.Join(' ', lines)).Trim();
return text.Length > FirstParagraphChars ? text[..FirstParagraphChars] : text;
}
+1 -1
View File
@@ -2,7 +2,7 @@ namespace Wiki.Application.Encyclopedia;
/// <summary>
/// Prompt texts of the encyclopedia. <see cref="Version"/> is bumped by hand whenever a prompt changes,
/// so that a prompt fix retries earlier rejections and failed plans.
/// so that a prompt fix retries earlier rejections and failed batches.
/// </summary>
public static class Prompts
{