desk: a stale answer whose card re-read hits an oversize fork is 422 fork_too_large

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
Heimdall 2026-11-11 01:38:35 +00:00
commit c4debdcb72
2 changed files with 13 additions and 3 deletions

View file

@ -229,6 +229,13 @@ public static class DeskEndpoints
if (string.Equals(result.Answer.Code, DeskStatus.StaleFork, StringComparison.Ordinal))
{
var current = await door.ReadAsync(mind.Socket, context, result.Answer.ForkId, cancellationToken);
if (current is DeskReadOutcome.ForkTooLarge(var largeFork))
{
// Nothing is recorded for a stale answer, and the card it would carry cannot be returned: permanent.
await WriteJsonAsync(http, DeskRefusals.ForkTooLargeStatus, DeskRefusals.ForkTooLargeDocument(largeFork));
return;
}
if (current is not DeskReadOutcome.Found(var entry))
{
await WriteUnavailableAsync(http, desk);

View file

@ -66,7 +66,7 @@ public sealed class DeskAnswerTests
}
[Fact]
public async Task A_stale_cards_read_that_is_fork_too_large_stays_unavailable_until_the_contract_says_otherwise()
public async Task A_stale_answers_card_read_of_an_oversize_fork_is_422_fork_too_large_naming_the_fork()
{
var (factory, token) = await ArrangeAsync();
using (factory)
@ -76,8 +76,11 @@ public sealed class DeskAnswerTests
var reply = await factory.SendAsync("POST", DeskReplay.Target("answer", "gamecult-chat", null), DeskReplay.AnswerBody(DeskReplay.ChatFork), token);
Assert.Equal(503, reply.Status);
Assert.Equal("unavailable", (string?)JsonNode.Parse(reply.Body)!["code"]);
var doc = JsonNode.Parse(reply.Body)!;
Assert.Equal(422, reply.Status);
Assert.Equal("fork_too_large", (string?)doc["code"]);
Assert.Contains(DeskReplay.ChatFork, (string)doc["error"]!);
Assert.Null(doc["card"]);
}
}