From 97ddba0cf5ee146212d299efc75feb451afdfb05 Mon Sep 17 00:00:00 2001 From: Heimdall Date: Wed, 11 Nov 2026 01:02:35 +0000 Subject: [PATCH] desk: request_id_conflict is the answer's alone; on read and list it is unavailable Co-Authored-By: Claude Sonnet 5.5 --- src/Bifrost.Web/Features/Desk/DeskEndpoints.cs | 6 ++++-- tests/Bifrost.Web.Tests/DeskReadTests.cs | 16 ++++++++++++++++ 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/src/Bifrost.Web/Features/Desk/DeskEndpoints.cs b/src/Bifrost.Web/Features/Desk/DeskEndpoints.cs index d09552a..7f5cfff 100644 --- a/src/Bifrost.Web/Features/Desk/DeskEndpoints.cs +++ b/src/Bifrost.Web/Features/Desk/DeskEndpoints.cs @@ -173,7 +173,7 @@ public static class DeskEndpoints { await WriteJsonAsync(http, DeskRefusals.ForkTooLargeStatus, DeskRefusals.ForkTooLargeDocument(largeId, largeOrder)); } - else if (listed is DeskListOutcome.NotListed(var listCode) && DoorMayRefuse(listCode)) + else if (listed is DeskListOutcome.NotListed(var listCode) && DoorMayRefuse(listCode) && listCode != DeskRefusals.RequestIdConflict) { await WriteRefusalAsync(http, ReadListCode(listCode)); } @@ -189,7 +189,7 @@ public static class DeskEndpoints { await WriteJsonAsync(http, 200, IsDecider(context) ? entry : DeskNotes.Strip(entry)); } - else if (found is DeskReadOutcome.NotFound(var readCode) && DoorMayRefuse(readCode)) + else if (found is DeskReadOutcome.NotFound(var readCode) && DoorMayRefuse(readCode) && readCode != DeskRefusals.RequestIdConflict) { await WriteRefusalAsync(http, ReadListCode(readCode)); } @@ -251,6 +251,8 @@ public static class DeskEndpoints code is not (DeskRefusals.Unauthenticated or DeskRefusals.InsufficientScope or DeskRefusals.Forbidden) && DeskRefusals.IsKnown(code); + // request_id_conflict is the answer's alone (Libby): a read or list carries no request_id, so the door saying it + // there is a door fault and the edge says `unavailable`. // A read or list sends no body. A door that refuses one for its body (an `authority` field among them) is // refusing the request, which is request_invalid; it is not an outage. private static string ReadListCode(string code) => diff --git a/tests/Bifrost.Web.Tests/DeskReadTests.cs b/tests/Bifrost.Web.Tests/DeskReadTests.cs index 38df03f..a713433 100644 --- a/tests/Bifrost.Web.Tests/DeskReadTests.cs +++ b/tests/Bifrost.Web.Tests/DeskReadTests.cs @@ -196,6 +196,22 @@ public sealed class DeskReadTests } } + [Fact] + public async Task request_id_conflict_is_the_answers_alone_on_read_and_list_it_is_a_door_fault() + { + using var factory = new DeskWebApplicationFactory(); + await factory.EnsureAccountAsync(DeskWebApplicationFactory.Alice, true); + + factory.Door.ReadScript = (_, _) => new DeskReadOutcome.NotFound(DeskRefusals.RequestIdConflict); + factory.Door.ListScript = (_, _) => new DeskListOutcome.NotListed(DeskRefusals.RequestIdConflict); + foreach (var target in new[] { "/api/desk/nibu/forks", DeskReplay.Target("read", "nibu", "nibu:question:glow-order") }) + { + var reply = await factory.SendAsync("GET", target, null, ReadToken(factory)); + Assert.Equal(503, reply.Status); + Assert.Equal("unavailable", (string?)JsonNode.Parse(reply.Body)!["code"]); + } + } + [Fact] public async Task Door_failure_on_list_and_read_is_unavailable() {