Registry: one throw for a missing or non-array ships; tests pin refusal codes, title bound and plan order

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Meta Vens 2026-10-10 21:39:04 +02:00
commit a43f90b48d
2 changed files with 38 additions and 10 deletions

View file

@ -43,16 +43,7 @@ public sealed class ConceptSubjectRegistry(
public static IReadOnlyList<ManifestShip> ParseManifest(string json)
{
using var document = ParseDocument(json);
if (document.RootElement.ValueKind != JsonValueKind.Object)
{
throw new ManifestRefusedException("ships", "Missing");
}
if (!document.RootElement.TryGetProperty("ships", out var ships))
{
throw new ManifestRefusedException("ships", "Missing");
}
var ships = ShipsOf(document.RootElement);
if (ships.ValueKind != JsonValueKind.Array)
{
throw new ManifestRefusedException("ships", "Missing");
@ -91,6 +82,16 @@ public sealed class ConceptSubjectRegistry(
return result;
}
private static JsonElement ShipsOf(JsonElement root)
{
if (root.ValueKind != JsonValueKind.Object)
{
return default;
}
return root.TryGetProperty("ships", out var ships) ? ships : default;
}
private static JsonDocument ParseDocument(string json)
{
try