Desk: re-pin CultLib card contract 3a51bbab and Huginn desk-feed fixtures 79d954c

Vectors re-vendored byte for byte (sha256 13afdcba...); ForkRecord gains
answerer_count, DeskAnswerDocument.Answerer is nullable, both required keys
(a missing one is a door fault, never an invented 0 or nil). The card stays opaque.
Huginn fixtures at 79d954c with UUID deciders, synthetic/proposed view fragments.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
Heimdall 2026-11-11 18:20:02 +00:00
commit f977a43d2a
35 changed files with 5015 additions and 1769 deletions

View file

@ -4,11 +4,12 @@ using System.Text.Json.Serialization;
namespace Bifrost.Web.Features.Desk;
// The fork-desk documents Bifrost reads or writes, spelled as CultLib's contracts/cultnet/governance/fork-card.md
// (commit de8a062a) spells them: snake_case keys, every key written (nil where absent), declared in the
// (commit 3a51bbab) spells them: snake_case keys, every key written (nil where absent), declared in the
// contract's key order. Bifrost authors only DeskRefusal and DeskUnavailable. AnswerRequest is the client's body;
// DeskAnswerDocument, ForkList and AnswerResult are Huginn's documents, typed here so they pass through unchanged.
// The card (gamecult.fork.card.v0) is deliberately NOT typed: its shape is still moving in CultLib (raised_at), and
// Bifrost neither reads nor edits it, so it is an opaque JsonElement that keeps every key, number and key order.
// The card (gamecult.fork.card.v0) is deliberately NOT typed: the Huginn door owns what a reader's card holds (the
// decider view carries ids, the non-decider view withholds them and keeps decider_count), and Bifrost neither reads
// nor edits it, so it is an opaque JsonElement that keeps every key, number and key order.
public static class DeskSchemas
{
@ -70,7 +71,9 @@ public sealed record DeskAnswerDocument(
[property: JsonPropertyName("answered_at")] string AnsweredAt,
[property: JsonPropertyName("received_at")] string ReceivedAt,
[property: JsonPropertyName("claim_in_future")] bool ClaimInFuture,
[property: JsonPropertyName("answerer")] string Answerer,
// Nil in a non-decider's view (Huginn withholds the ids); the key is required, so a missing one is a door fault,
// never a nil Bifrost invented.
[property: JsonPropertyName("answerer"), JsonRequired] string? Answerer,
[property: JsonPropertyName("authority")] string Authority,
[property: JsonPropertyName("request_id")] string RequestId);
@ -79,6 +82,7 @@ public sealed record ForkRecord(
[property: JsonPropertyName("fork_id")] string ForkId,
[property: JsonPropertyName("options_hash")] string OptionsHash,
[property: JsonPropertyName("counted_answer_id")] string? CountedAnswerId,
[property: JsonPropertyName("answerer_count"), JsonRequired] int AnswererCount,
[property: JsonPropertyName("answers")] DeskAnswerDocument[] Answers);
public sealed record ForkEntry(

View file

@ -64,7 +64,7 @@ public sealed class DeskDocumentTests
public void Cards_round_trip_with_their_spelling()
{
var rows = DeskVectors.Rows("card", "valid").ToList();
Assert.Equal(5, rows.Count);
Assert.Equal(7, rows.Count);
foreach (var row in rows)
{
var message = row["message"]!;
@ -82,7 +82,7 @@ public sealed class DeskDocumentTests
"\"future\":{\"z\":1.50,\"a\":[3,null,1e2],\"big\":12345678901234567890},\"options_hash\":\"ab\",\"leans\":null}";
var entryJson =
"{\"schemaVersion\":\"gamecult.fork.entry.v0\",\"card\":" + card +
",\"record\":{\"schemaVersion\":\"gamecult.fork.record.v0\",\"fork_id\":\"x:question:y\",\"options_hash\":\"ab\",\"counted_answer_id\":null,\"answers\":[]}}";
",\"record\":{\"schemaVersion\":\"gamecult.fork.record.v0\",\"fork_id\":\"x:question:y\",\"options_hash\":\"ab\",\"counted_answer_id\":null,\"answerer_count\":0,\"answers\":[]}}";
var entry = JsonSerializer.Deserialize<ForkEntry>(entryJson, DeskJson.Options)!;
var written = JsonSerializer.Serialize(entry, DeskJson.Options);

View file

@ -3,28 +3,32 @@ using System.Security.Cryptography;
namespace Bifrost.Web.Tests;
// Huginn's desk-feed golden bytes, vendored byte for byte from
// crates/huginn-mind/tests/fixtures/desk-feed/ at Huginn commit 9dde93e (docs/desk-feed-door.md is the contract).
// crates/huginn-mind/tests/fixtures/desk-feed/ at Huginn commit 79d954c (docs/desk-feed-door.md is the contract).
// A silent re-vendor fails here: move the pin on purpose, with the contract and the door's tests.
public sealed class DeskFeedFixturePinTests
{
public const string HuginnCommit = "9dde93e";
public const string HuginnCommit = "79d954c";
public static readonly string Directory = Path.Combine(AppContext.BaseDirectory, "Fixtures", "desk-feed");
private static readonly Dictionary<string, string> Sha256 = new(StringComparer.Ordinal)
{
[".gitattributes"] = "171872d6445cb1ffef0263b613d1ac318a60398449831d4cc4f772f78a7ebcff",
["README.md"] = "e2529f2bfedaf986a3f0df100c60ca2a4c46a74c83845d4d9c02d5c9a35dcb88",
["README.md"] = "441636e7b122289181ff999f2de51e8ca59fbab5782b7e05e1002bcca9657c48",
["card-viewers-decider.synthetic.payload.hex"] = "13e0d20ed4c07d638417a39237f17d96c5decd659be47b0d022d26712980ec15",
["card-viewers-decider.synthetic.payload.msgpack"] = "c5c2d9b1f4f08b0049227a9cb9deb850bc9a7a74acd7ad6c85b15d2433133dee",
["card-viewers-non-decider.synthetic.payload.hex"] = "e59938dff11230981bf51241d89091df76d2ca36b563f2a65dea58873844bf8c",
["card-viewers-non-decider.synthetic.payload.msgpack"] = "003fe7bb3ac93dc5cdf56fa1eca003f720d423fb1260778882ce5354729a1027",
["error.response.frame.bin"] = "fa03f44b82d7c4796f45dd36086a54342dc1de7e660a58cf3ddff4ff59d85a4c",
["error.response.frame.hex"] = "21c75b6e1d000ddc1a5455a9cc4d6c5b37bd1640c22e1055e96ff85bdff461bb",
["failure.response.frame.bin"] = "edc2277943334744d3057902800c25bbc913ff8ed336b4612f1a19772ec46dc9",
["failure.response.frame.hex"] = "b3c262ac506b51529e8063b2d38cc8c0047b431b75fe6ede1a91adebefd014d3",
["failure.response.payload.hex"] = "13ca85b5868451892746d2531833d394b66d25b5069cd0208169c5fcc94bf350",
["failure.response.payload.msgpack"] = "4bf7c80eb2d75b9559ab430757a98ebfd424745ed3fc1888d21bc6e41ed99403",
["list-counts.request.frame.bin"] = "1c04651e0b5b00c1ea955c19a07694c887010a5dbed3c56c745eb08b2e86a525",
["list-counts.request.frame.hex"] = "38f70d81ad9d6622e259147f8d092e1d1a506dbff41509736a78b514fd87c33b",
["list-counts.request.payload.hex"] = "b4ed23985d7b2ff45710fce0f0969cc9a8e421d1f7f01c5d8bc0e1a4f9c014bf",
["list-counts.request.payload.msgpack"] = "738646e54e0ec239d309b3bc3d8513e73db9dd2e7ea9df0a6a29ad999d3e2fa8",
["list-counts.request.frame.bin"] = "be338fc06f127f9c20f82952708ffe95f8b6b8de7c5098834eb8cb257893637f",
["list-counts.request.frame.hex"] = "496bbc58292a1d029361bd553eef2ccf786cfa6520b1a3ad97c831893c36cf50",
["list-counts.request.payload.hex"] = "5ec076a5d8006a0290ad269deffb2bfe45ac7ee8b6a11ea2d4968a6ac8603e4b",
["list-counts.request.payload.msgpack"] = "52f244c3d704067f79561c8d46f4069ac3f4452a73d916fb92154d28b28ea6c7",
["list-counts.response.frame.bin"] = "bf51c933fbbaa61934907cb66f5e07ac813de48e849ac80bdf3ba4f75d3952a3",
["list-counts.response.frame.hex"] = "3f395ae2302d0882fb2456fe94512bba045a1c967f98b4ebf6b306dd5e3d74a3",
["list-counts.response.payload.hex"] = "9a6f6b0be985d6ff8d313fa9e12ffe6662a59ff7305e574f4bfe8bf9a3ce2291",
@ -33,14 +37,14 @@ public sealed class DeskFeedFixturePinTests
["list-empty.response.frame.hex"] = "9b0f15bf8948e44f9e43718914f6621402c98c06e0d21bf90640c521ab7f1a45",
["list-empty.response.payload.hex"] = "d93cd65c1d9f4fc052b9c7f17d16ea6e468a7af296cafd6a31d671ae855d2860",
["list-empty.response.payload.msgpack"] = "7b1a26f303d3bdd0317d24a0eb4a2d9144ada0a878c927905a1a345efabf3a9f",
["list-open-cursor.request.frame.bin"] = "c73283d1e1e774abf66a6e4011ccc5c3f723a81cc2a4d3eb39575411479e7051",
["list-open-cursor.request.frame.hex"] = "b8a1716d9a1d6c1ece46dc8cdafa8a9efaa5474596ae41facd95fe8efcbad6f5",
["list-open-cursor.request.payload.hex"] = "0901e276fa578bb30792d925a0a2d0b65a09629d7b2493d4e666c714127df531",
["list-open-cursor.request.payload.msgpack"] = "5fd85c8418ea8f15313178c3410f9d21a8f0cc0bdbadbf5c56f3fa825a9869b9",
["list-open.request.frame.bin"] = "30ca39b84d3fa4c0562ad4707db765f35d2e0f2bcd42695e2595b6f8fafb3866",
["list-open.request.frame.hex"] = "ca4b065102699f7998040b5d0a396a088b2f7254ff1a6801fa1d648746453d3f",
["list-open.request.payload.hex"] = "960f570d6f76691ba75e4adb81b80e836612282ee0f88993be4754f60b00d461",
["list-open.request.payload.msgpack"] = "4f6ca021ff72d59869359ffb296bd93706ef13d86e8aea4efe5bcf11f4b59bd6",
["list-open-cursor.request.frame.bin"] = "13671e1c83c10350d86b149a86a98b69763b9a3e40eae0024c10f3e70b96ef8b",
["list-open-cursor.request.frame.hex"] = "e2270f26d122374554855bf60686edbc5d4abfd63374cde08ab479a5f310aa12",
["list-open-cursor.request.payload.hex"] = "437f4c0cbdc712e9b3f8e1f8666cf8ffe88061cce8d0da3a64e648eb7b6bb27f",
["list-open-cursor.request.payload.msgpack"] = "05889e90f8143aa1a1375539f6e76593a682413b70cb40a8aaa3c7db2882622a",
["list-open.request.frame.bin"] = "2af34627a45d7bfca034b880bf61f5dfd78022a8df425f418c0a084181663903",
["list-open.request.frame.hex"] = "03f74ba78996b2ccb3fcf5fb712ae1d19f7594099ba04250ee0223c8631b9a24",
["list-open.request.payload.hex"] = "a58e8583d41d4a04cbd983c6b5a8bdae26105f2eb7f25dfb7d5f86aa81847e93",
["list-open.request.payload.msgpack"] = "431e000c3f002c254adc57273557c8111e815ca42a8dd4272762d3e7697d7f0a",
["list-response-too-large.response.frame.bin"] = "b95218e48c1f8e4162f515b97a85c324b9ccfe2b3216780ed0eca1d2e2066f19",
["list-response-too-large.response.frame.hex"] = "b4bedb2c59b1362e5059caf6dbea63952b8fe9c47b681da3825422bc677f8632",
["list-response-too-large.response.payload.hex"] = "4f5f18915e0e536c387e659eb2021570a5b0bc5e0f530521ca226dc687d6780d",
@ -57,12 +61,14 @@ public sealed class DeskFeedFixturePinTests
["read-unknown.response.frame.hex"] = "97ab11a04a2d62917186b23666ed26ef09df220ffb1c3e188d919985085733e2",
["read-unknown.response.payload.hex"] = "ca8d4d1fa4d40915b6e062767967e62343b360ce669801da96d99509e24787fb",
["read-unknown.response.payload.msgpack"] = "0d4fe47159db88b5048bc1f42a0e72857b568eac48572777a0c896ee94f7c208",
["read.request.frame.bin"] = "702d5a0a80bf05b75b24eff5a3f889ab0c96e819b8ca172e77bae05d74895662",
["read.request.frame.hex"] = "79c951722dd939212cb33635270dec11f47debd979960e8d4f74f2ecfd83708a",
["read.request.payload.hex"] = "3202f08616589a3d56bc36299b9915d1f8de8d2cd5573d21bca9115d30d9d968",
["read.request.payload.msgpack"] = "c10a27f67a4a2512d06c01528e1ee59754f9cc2e5a1b244b9982268bc8b4d2e0",
["record-whole.payload.hex"] = "f1fcee6923dbed3b49153e552e045af0e5be415fd857583e52ea519553784c46",
["record-whole.payload.msgpack"] = "1687ef965066e1a7e264ccd10760449ce14f28b2042c67f7d7944b0db2275581",
["read.request.frame.bin"] = "3a9bc16ce4ce706e8c839bf4cfe65d3e2fdf759992555e68be6fc7bcc15653ea",
["read.request.frame.hex"] = "3c3d9540c4af789d230b7108f98d5d5f3dd9b291ff618064ddc374eb2a7bb082",
["read.request.payload.hex"] = "48aed263254eac7bc156c1af1f2ee210a08dda2b453a5be2dc17083ab73800b2",
["read.request.payload.msgpack"] = "c5447f462247703af4329e071bc0ac14dce1cb94a63c85517400791d022263ca",
["record-non-decider.proposed.payload.hex"] = "15350e035612b380b55811c90b218afb7444214a2965deae35076aabe78206e5",
["record-non-decider.proposed.payload.msgpack"] = "5095dfb375613a5f80a4471e1d5b68c77890b0732dc03cc11e52d9e769406afc",
["record-whole.payload.hex"] = "f70d1a81a4f1031c04d5e1750f9162afc859a7b4d5b4cacf3e562d60ac00f531",
["record-whole.payload.msgpack"] = "3ad3926b024fb76178cd68cbdab6a28da1ddef9a3aca6b66050488213145d496",
["refused-unit.response.frame.bin"] = "4f86943a6947dd3c6041ee7d1b52d3f73697604dd224ca5dcf5b66064b0de1f1",
["refused-unit.response.frame.hex"] = "f25f35911d242d6fdb7ac4e1ecb3fe01901aa4b816d957104bde6f21b29a1bed",
["refused-unit.response.payload.hex"] = "858d49c8c66ce1b9c32160e2aecb320a8c00166728c80f5a02d62ec90b4f410d",
@ -74,7 +80,7 @@ public sealed class DeskFeedFixturePinTests
};
[Fact]
public void Fixtures_are_huginn_9dde93e_byte_for_byte()
public void Fixtures_are_huginn_79d954c_byte_for_byte()
{
var present = new DirectoryInfo(Directory).GetFiles().Select(f => f.Name).Order(StringComparer.Ordinal).ToArray();
Assert.Equal(Sha256.Keys.Order(StringComparer.Ordinal).ToArray(), present);

View file

@ -102,7 +102,7 @@ public sealed class DeskReadTests
}
}
Assert.Equal(9, steps);
Assert.Equal(10, steps);
}
[Fact]

View file

@ -0,0 +1,148 @@
using System.Text.Json;
using System.Text.Json.Nodes;
using Bifrost.Web.Features.Desk;
using Bifrost.Web.Tests.Support;
namespace Bifrost.Web.Tests;
// CultLib 3a51bbab's reader views, as Bifrost meets them: the 17-key card (raised_at, decider_count) stays opaque,
// the record is typed with answerer_count, and answerer is nil in a non-decider's view.
public sealed class DeskReaderViewTests
{
private static readonly string[] CardKeys =
[
"schemaVersion", "fork_id", "title", "context", "options", "recommendation", "depends", "leans", "flag", "raised_in",
"raised_at", "deciders", "decider_count", "status", "ruling", "ruled_from", "order", "options_hash",
];
[Fact]
public void Valid_cards_are_the_17_key_card_with_both_views_and_pass_through_unchanged()
{
var rows = DeskVectors.Rows("card", "valid").ToList();
Assert.Equal(7, rows.Count);
foreach (var row in rows)
{
var message = row["message"]!.AsObject();
Assert.Equal(CardKeys, message.Select(p => p.Key));
Assert.StartsWith("DE0012", (string)row["messagePackHex"]!, StringComparison.Ordinal);
Assert.True(message["raised_at"] is null || message["raised_at"]!.GetValueKind() == JsonValueKind.String);
var count = (int)message["decider_count"]!;
Assert.InRange(count, 1, 64);
var deciders = message["deciders"]!.AsArray();
Assert.True(deciders.Count == 0 || deciders.Count == count, (string)row["name"]!);
var card = message.Deserialize<JsonElement>(DeskJson.Options);
Assert.True(DeskVectors.SameShape(message, JsonSerializer.SerializeToNode(card, DeskJson.Options)), (string)row["name"]!);
}
Assert.Contains(rows, r => r["message"]!["raised_at"] is null);
Assert.Contains(rows, r => r["message"]!["deciders"]!.AsArray().Count == 0 && (string)r["name"]! == "withheld_deciders");
}
[Fact]
public void The_options_hash_vectors_are_the_15_and_Bifrost_computes_no_hash()
{
Assert.Equal(15, DeskVectors.Array("optionsHash").Count);
var directory = new DirectoryInfo(AppContext.BaseDirectory);
while (directory is not null && !Directory.Exists(Path.Combine(directory.FullName, "src", "Bifrost.Web", "Features", "Desk")))
{
directory = directory.Parent;
}
Assert.NotNull(directory);
foreach (var file in Directory.GetFiles(Path.Combine(directory.FullName, "src", "Bifrost.Web", "Features", "Desk"), "*.cs"))
{
var text = File.ReadAllText(file);
Assert.DoesNotContain("System.Security.Cryptography", text, StringComparison.Ordinal);
Assert.DoesNotContain("SHA256", text, StringComparison.Ordinal);
}
}
[Fact]
public void Stored_answers_round_trip_and_every_variant_carries_a_nil_answerer_with_the_key_written()
{
var rows = DeskVectors.Rows("deskAnswer", "valid").ToList();
Assert.Equal(6, rows.Count);
Assert.Contains(rows, r => (string)r["name"]! == "withheld_answerer");
var outcomes = new HashSet<string>();
foreach (var row in rows)
{
var message = row["message"]!.AsObject();
Assert.StartsWith("DE0010", (string)row["messagePackHex"]!, StringComparison.Ordinal);
outcomes.Add((string)message["outcome"]!);
Assert.True(DeskVectors.SameShape(message, JsonSerializer.SerializeToNode(message.Deserialize<DeskAnswerDocument>(DeskJson.Options), DeskJson.Options)), (string)row["name"]!);
var withheld = JsonNode.Parse(message.ToJsonString())!.AsObject();
withheld["answerer"] = null;
var back = JsonSerializer.SerializeToNode(withheld.Deserialize<DeskAnswerDocument>(DeskJson.Options), DeskJson.Options)!.AsObject();
Assert.True(back.ContainsKey("answerer"));
Assert.Null(back["answerer"]);
Assert.True(DeskVectors.SameShape(withheld, back), (string)row["name"]!);
}
Assert.Superset(new HashSet<string> { "Counted", "Revision", "Retraction", "Refused" }, outcomes);
}
[Fact]
public void Entries_in_both_views_round_trip_and_the_shape_faults_Bifrost_can_see_are_refused()
{
var valid = DeskVectors.Rows("transport", "entry", "valid").ToList();
Assert.Equal(6, valid.Count);
foreach (var row in valid)
{
var message = row["message"]!;
Assert.True(DeskVectors.SameShape(message, JsonSerializer.SerializeToNode(message.Deserialize<ForkEntry>(DeskJson.Options), DeskJson.Options)), (string)row["name"]!);
}
// Missing or null answerer_count is not a count Bifrost may invent; the other invalid entries are rules of the
// contract's validators (CultLib) and Huginn's door, which Bifrost does not judge.
foreach (var name in new[] { "answerer_count_missing", "answerer_count_null" })
{
var row = DeskVectors.Rows("transport", "entry", "invalid").First(r => (string)r["name"]! == name);
Assert.ThrowsAny<JsonException>(() => row["message"].Deserialize<ForkEntry>(DeskJson.Options));
}
}
[Fact]
public void Every_scenario_record_is_the_6_key_record_and_decodes_typed()
{
var count = 0;
foreach (var scenario in DeskVectors.Rows("scenarios"))
{
var record = scenario["record"]!;
Assert.StartsWith("86", (string)scenario["recordHex"]!, StringComparison.Ordinal);
Assert.True(DeskVectors.SameShape(record, JsonSerializer.SerializeToNode(record.Deserialize<ForkRecord>(DeskJson.Options), DeskJson.Options)), (string)scenario["name"]!);
count++;
}
Assert.Equal(63, count);
}
[Fact]
public async Task The_non_decider_page_leaves_the_edge_with_notes_nil_and_ids_withheld_untouched()
{
var scenario = DeskVectors.Rows("transport", "listScenarios").First(s => (string)s["name"]! == "non_decider_page");
using var factory = new DeskWebApplicationFactory();
await factory.EnsureAccountAsync(DeskWebApplicationFactory.Member, true);
var step = scenario["steps"]![0]!;
var response = step["response"]!.AsObject();
factory.Door.ListScript = (_, _) => new DeskListOutcome.Listed(response.Deserialize<ForkList>(DeskJson.Options)!);
var request = step["request"]!;
var reply = await factory.SendAsync(
"GET", $"/api/desk/{(string)request["mind"]!}/forks?status={(string?)request["status"]}&cursor={(string?)request["cursor"]}&limit={(int)request["limit"]!}",
null, factory.Token(DeskWebApplicationFactory.Member, "bifrost-desk", "desk.read"));
Assert.Equal(200, reply.Status);
var expected = JsonNode.Parse(response.ToJsonString())!;
foreach (var fork in expected["forks"]!.AsArray())
{
foreach (var answer in fork!["record"]!["answers"]!.AsArray())
{
answer!["note"] = null;
}
}
Assert.True(DeskVectors.SameShape(JsonNode.Parse(reply.Body), expected));
}
}

View file

@ -6,7 +6,7 @@ namespace Bifrost.Web.Tests;
public sealed class DeskVectorPinTests
{
[Fact]
public void Vectors_are_cultlib_de8a062a()
public void Vectors_are_cultlib_3a51bbab()
{
var sha = Convert.ToHexString(SHA256.HashData(File.ReadAllBytes(DeskVectors.Path))).ToLowerInvariant();

View file

@ -35,7 +35,10 @@ lands (see `docs/desk-feed-door.md`).
| `unavailable.response` | Huginn to Bifrost | `Refused` `Unavailable` (Bifrost: 503 for this Mind) |
| `failure.response` | Huginn to Bifrost | operation failure, `payloadSchema` `gamecult.cultnet.operation_failure.v1` (Bifrost: 503) |
| `error.response` | Huginn to Bifrost | CultNet `Error` message, no payload (Bifrost: 503) |
| `record-whole` | fragment | `gamecult.fork.record.v0` with a counted answer and a revision, answerer ids and notes raw, as the door sends them (Bifrost masks for a reader who is not a decider) |
| `record-whole` | fragment | `gamecult.fork.record.v0` with a counted answer and a revision, answerer ids and notes whole: what the door sends today, and a decider's view |
| `record-non-decider.proposed` | fragment | PROPOSED non-decider record: every `answerer` nil, `answerer_count` 2. Needs CultLib change `cultlib-fork-card-reader-counts`; not Huginn output yet |
| `card-viewers-decider.synthetic` | fragment | SYNTHETIC: only `{deciders: [two ids], decider_count: 2}`. Not a card |
| `card-viewers-non-decider.synthetic` | fragment | SYNTHETIC: only `{deciders: [], decider_count: 2}`. Not a card |
No case carries a card (`gamecult.fork.card.v0`). The card's bytes wait on CultLib's re-pinned card
vectors for `raised_at`, so no entry-bearing list page or read is pinned yet.

View file

@ -0,0 +1 @@
82a8646563696465727392d92435663063326231652d386134642d346333622d396537662d316132623363346435653666d92430623964376533612d366332312d346635382d613064342d396538663761366235633464ad646563696465725f636f756e7402

View file

@ -0,0 +1 @@
‚¨deciders’Ù$5f0c2b1e-8a4d-4c3b-9e7f-1a2b3c4d5e6fÙ$0b9d7e3a-6c21-4f58-a0d4-9e8f7a6b5c4d­decider_count

View file

@ -0,0 +1 @@
82a8646563696465727390ad646563696465725f636f756e7402

View file

@ -0,0 +1 @@
‚¨deciders<EFBFBD>­decider_count

View file

@ -1 +1 @@
0000011287a96d6573736167654964a36d2d33a96f7065726174696f6ea5666f726b73a77061796c6f6164d9606761564762334a726334616b62576c755a4b5a6c64584a6c6132476e63335669616d566a644b45337147526c59326c6b5a584a7a6b7145336f6a4579706e4e30595852316336527663475675706d4e31636e4e766373436c62476c7461585141af7061796c6f6164456e636f64696e67b26d6573736167657061636b2d626173653634ad7061796c6f6164536368656d61b6687567696e6e2e6465736b5f726571756573742e7631ad736368656d6156657273696f6ebc63756c746e65742e6f7065726174696f6e5f726571756573742e7630a9736572766963654964ab687567696e6e2e6465736b
000001a287a96d6573736167654964a36d2d33a96f7065726174696f6ea5666f726b73a77061796c6f6164d9f06761564762334a726334616b62576c755a4b5a6c64584a6c6132476e63335669616d566a644e6b6b4e575977597a4a694d5755744f4745305a433030597a4e694c546c6c4e3259744d574579596a4e6a4e4751315a545a6d7147526c59326c6b5a584a7a6b746b6b4e575977597a4a694d5755744f4745305a433030597a4e694c546c6c4e3259744d574579596a4e6a4e4751315a545a6d32535177596a6c6b4e32557a59533032597a49784c54526d4e5467745954426b4e4330355a54686d4e324532596a566a4e47536d633352686448567a704739775a57366d5933567963323979774b5673615731706441413daf7061796c6f6164456e636f64696e67b26d6573736167657061636b2d626173653634ad7061796c6f6164536368656d61b6687567696e6e2e6465736b5f726571756573742e7631ad736368656d6156657273696f6ebc63756c746e65742e6f7065726174696f6e5f726571756573742e7630a9736572766963654964ab687567696e6e2e6465736b

View file

@ -1 +1 @@
81a5466f726b7386a46d696e64a6657572656b61a77375626a656374a137a8646563696465727392a137a23132a6737461747573a46f70656ea6637572736f72c0a56c696d697400
81a5466f726b7386a46d696e64a6657572656b61a77375626a656374d92435663063326231652d386134642d346333622d396537662d316132623363346435653666a8646563696465727392d92435663063326231652d386134642d346333622d396537662d316132623363346435653666d92430623964376533612d366332312d346635382d613064342d396538663761366235633464a6737461747573a46f70656ea6637572736f72c0a56c696d697400

View file

@ -1 +1 @@
0000011687a96d6573736167654964a36d2d32a96f7065726174696f6ea5666f726b73a77061796c6f6164d9646761564762334a726334616b62576c755a4b5a6c64584a6c6132476e63335669616d566a644b45337147526c59326c6b5a584a7a6b7145336f6a4579706e4e30595852316336527663475675706d4e31636e4e7663714e6a4e444b6c62476c7461585179af7061796c6f6164456e636f64696e67b26d6573736167657061636b2d626173653634ad7061796c6f6164536368656d61b6687567696e6e2e6465736b5f726571756573742e7631ad736368656d6156657273696f6ebc63756c746e65742e6f7065726174696f6e5f726571756573742e7630a9736572766963654964ab687567696e6e2e6465736b
000001a687a96d6573736167654964a36d2d32a96f7065726174696f6ea5666f726b73a77061796c6f6164d9f46761564762334a726334616b62576c755a4b5a6c64584a6c6132476e63335669616d566a644e6b6b4e575977597a4a694d5755744f4745305a433030597a4e694c546c6c4e3259744d574579596a4e6a4e4751315a545a6d7147526c59326c6b5a584a7a6b746b6b4e575977597a4a694d5755744f4745305a433030597a4e694c546c6c4e3259744d574579596a4e6a4e4751315a545a6d32535177596a6c6b4e32557a59533032597a49784c54526d4e5467745954426b4e4330355a54686d4e324532596a566a4e47536d633352686448567a704739775a57366d59335679633239796f324d304d715673615731706444493daf7061796c6f6164456e636f64696e67b26d6573736167657061636b2d626173653634ad7061796c6f6164536368656d61b6687567696e6e2e6465736b5f726571756573742e7631ad736368656d6156657273696f6ebc63756c746e65742e6f7065726174696f6e5f726571756573742e7630a9736572766963654964ab687567696e6e2e6465736b

View file

@ -1 +1 @@
81a5466f726b7386a46d696e64a6657572656b61a77375626a656374a137a8646563696465727392a137a23132a6737461747573a46f70656ea6637572736f72a3633432a56c696d697432
81a5466f726b7386a46d696e64a6657572656b61a77375626a656374d92435663063326231652d386134642d346333622d396537662d316132623363346435653666a8646563696465727392d92435663063326231652d386134642d346333622d396537662d316132623363346435653666d92430623964376533612d366332312d346635382d613064342d396538663761366235633464a6737461747573a46f70656ea6637572736f72a3633432a56c696d697432

View file

@ -1 +1 @@
<EFBFBD>¥Forks†¤mind¦eureka§subject¡7¨deciders’¡7¢12¦status¤open¦cursor£c42¥limit2
<EFBFBD>¥Forks†¤mind¦eureka§subjectÙ$5f0c2b1e-8a4d-4c3b-9e7f-1a2b3c4d5e6f¨deciders’Ù$5f0c2b1e-8a4d-4c3b-9e7f-1a2b3c4d5e6fÙ$0b9d7e3a-6c21-4f58-a0d4-9e8f7a6b5c4d¦status¤open¦cursor£c42¥limit2

View file

@ -1 +1 @@
0000011287a96d6573736167654964a36d2d31a96f7065726174696f6ea5666f726b73a77061796c6f6164d9606761564762334a726334616b62576c755a4b5a6c64584a6c6132476e63335669616d566a644b45337147526c59326c6b5a584a7a6b7145336f6a4579706e4e30595852316336527663475675706d4e31636e4e766373436c62476c7461585179af7061796c6f6164456e636f64696e67b26d6573736167657061636b2d626173653634ad7061796c6f6164536368656d61b6687567696e6e2e6465736b5f726571756573742e7631ad736368656d6156657273696f6ebc63756c746e65742e6f7065726174696f6e5f726571756573742e7630a9736572766963654964ab687567696e6e2e6465736b
000001a287a96d6573736167654964a36d2d31a96f7065726174696f6ea5666f726b73a77061796c6f6164d9f06761564762334a726334616b62576c755a4b5a6c64584a6c6132476e63335669616d566a644e6b6b4e575977597a4a694d5755744f4745305a433030597a4e694c546c6c4e3259744d574579596a4e6a4e4751315a545a6d7147526c59326c6b5a584a7a6b746b6b4e575977597a4a694d5755744f4745305a433030597a4e694c546c6c4e3259744d574579596a4e6a4e4751315a545a6d32535177596a6c6b4e32557a59533032597a49784c54526d4e5467745954426b4e4330355a54686d4e324532596a566a4e47536d633352686448567a704739775a57366d5933567963323979774b5673615731706444493daf7061796c6f6164456e636f64696e67b26d6573736167657061636b2d626173653634ad7061796c6f6164536368656d61b6687567696e6e2e6465736b5f726571756573742e7631ad736368656d6156657273696f6ebc63756c746e65742e6f7065726174696f6e5f726571756573742e7630a9736572766963654964ab687567696e6e2e6465736b

View file

@ -1 +1 @@
81a5466f726b7386a46d696e64a6657572656b61a77375626a656374a137a8646563696465727392a137a23132a6737461747573a46f70656ea6637572736f72c0a56c696d697432
81a5466f726b7386a46d696e64a6657572656b61a77375626a656374d92435663063326231652d386134642d346333622d396537662d316132623363346435653666a8646563696465727392d92435663063326231652d386134642d346333622d396537662d316132623363346435653666d92430623964376533612d366332312d346635382d613064342d396538663761366235633464a6737461747573a46f70656ea6637572736f72c0a56c696d697432

View file

@ -1 +1 @@
<EFBFBD>¥Forks†¤mind¦eureka§subject¡7¨deciders’¡7¢12¦status¤open¦cursorÀ¥limit2
<EFBFBD>¥Forks†¤mind¦eureka§subjectÙ$5f0c2b1e-8a4d-4c3b-9e7f-1a2b3c4d5e6f¨deciders’Ù$5f0c2b1e-8a4d-4c3b-9e7f-1a2b3c4d5e6fÙ$0b9d7e3a-6c21-4f58-a0d4-9e8f7a6b5c4d¦status¤open¦cursorÀ¥limit2

View file

@ -1 +1 @@
0000013987a96d6573736167654964a36d2d34a96f7065726174696f6ea4666f726ba77061796c6f6164d9886761524762334a72684b52746157356b706d5631636d56725961647a64574a715a574e306f54656f5a47566a6157526c636e4f536f5465694d544b6e5a6d3979613139705a4e6b775a5856795a5774684c584e31596e4e30636d46305a5470786457567a64476c76626a706b5a584e724c57787063335270626d6374595856306147397961585235af7061796c6f6164456e636f64696e67b26d6573736167657061636b2d626173653634ad7061796c6f6164536368656d61b6687567696e6e2e6465736b5f726571756573742e7631ad736368656d6156657273696f6ebc63756c746e65742e6f7065726174696f6e5f726571756573742e7630a9736572766963654964ab687567696e6e2e6465736b
000001ca87a96d6573736167654964a36d2d34a96f7065726174696f6ea4666f726ba77061796c6f6164da01186761524762334a72684b52746157356b706d5631636d56725961647a64574a715a574e30325351315a6a426a4d6d49785a5330345954526b4c54526a4d3249744f5755335a69307859544a694d324d305a44566c4e6d616f5a47566a6157526c636e4f53325351315a6a426a4d6d49785a5330345954526b4c54526a4d3249744f5755335a69307859544a694d324d305a44566c4e6d625a4a4442694f5751335a544e684c545a6a4d6a45744e4759314f4331684d4751304c546c6c4f47593359545a694e574d305a4b646d62334a7258326c6b3254426c64584a6c6132457463335669633352795958526c4f6e46315a584e30615739754f6d526c6332737462476c7a64476c755a7931686458526f62334a7064486b3daf7061796c6f6164456e636f64696e67b26d6573736167657061636b2d626173653634ad7061796c6f6164536368656d61b6687567696e6e2e6465736b5f726571756573742e7631ad736368656d6156657273696f6ebc63756c746e65742e6f7065726174696f6e5f726571756573742e7630a9736572766963654964ab687567696e6e2e6465736b

View file

@ -1 +1 @@
81a4466f726b84a46d696e64a6657572656b61a77375626a656374a137a8646563696465727392a137a23132a7666f726b5f6964d930657572656b612d7375627374726174653a7175657374696f6e3a6465736b2d6c697374696e672d617574686f72697479
81a4466f726b84a46d696e64a6657572656b61a77375626a656374d92435663063326231652d386134642d346333622d396537662d316132623363346435653666a8646563696465727392d92435663063326231652d386134642d346333622d396537662d316132623363346435653666d92430623964376533612d366332312d346635382d613064342d396538663761366235633464a7666f726b5f6964d930657572656b612d7375627374726174653a7175657374696f6e3a6465736b2d6c697374696e672d617574686f72697479

View file

@ -1 +1 @@
<EFBFBD>¤Fork„¤mind¦eureka§subject¡7¨deciders’¡7¢12§fork_idÙ0eureka-substrate:question:desk-listing-authority
<EFBFBD>¤Fork„¤mind¦eureka§subjectÙ$5f0c2b1e-8a4d-4c3b-9e7f-1a2b3c4d5e6f¨deciders’Ù$5f0c2b1e-8a4d-4c3b-9e7f-1a2b3c4d5e6fÙ$0b9d7e3a-6c21-4f58-a0d4-9e8f7a6b5c4d§fork_idÙ0eureka-substrate:question:desk-listing-authority

View file

@ -0,0 +1 @@
86ad736368656d6156657273696f6eb767616d6563756c742e666f726b2e7265636f72642e7630a7666f726b5f6964d930657572656b612d7375627374726174653a7175657374696f6e3a6465736b2d6c697374696e672d617574686f72697479ac6f7074696f6e735f68617368d94037643935666338376435333234323036313166653431356331646566323761333434373631376262363832333566343665336166313330616561333631633438b1636f756e7465645f616e737765725f6964a26e31ae616e7377657265725f636f756e7402a7616e737765727392de0010ad736368656d6156657273696f6eb767616d6563756c742e6465736b5f616e737765722e7630a9616e737765725f6964a26e31a7666f726b5f6964d930657572656b612d7375627374726174653a7175657374696f6e3a6465736b2d6c697374696e672d617574686f72697479a76f7574636f6d65a7436f756e746564a26f66c0a87265747261637473c0a4636f6465c0ac6f7074696f6e735f68617368d94037643935666338376435333234323036313166653431356331646566323761333434373631376262363832333566343665336166313330616561333631633438a663686f696365ab61736b696e672d6d696e64a46e6f7465be5468652061736b6572206c6973747320686572206f776e20666f726b732eab616e7377657265645f6174b4323032362d31312d31315431373a30303a30305aab72656365697665645f6174b4323032362d31312d31315431373a30303a30305aaf636c61696d5f696e5f667574757265c2a8616e737765726572c0a9617574686f72697479a64d656d626572aa726571756573745f6964d92430303030303030302d303030302d343030302d383030302d303030303030303030303031de0010ad736368656d6156657273696f6eb767616d6563756c742e6465736b5f616e737765722e7630a9616e737765725f6964a26e32a7666f726b5f6964d930657572656b612d7375627374726174653a7175657374696f6e3a6465736b2d6c697374696e672d617574686f72697479a76f7574636f6d65a85265766973696f6ea26f66a26e31a87265747261637473c0a4636f6465c0ac6f7074696f6e735f68617368d94037643935666338376435333234323036313166653431356331646566323761333434373631376262363832333566343665336166313330616561333631633438a663686f696365ab61736b696e672d6d696e64a46e6f7465a74167726565642eab616e7377657265645f6174b4323032362d31312d31315431373a30353a30305aab72656365697665645f6174b4323032362d31312d31315431373a30353a30305aaf636c61696d5f696e5f667574757265c2a8616e737765726572c0a9617574686f72697479a64d656d626572aa726571756573745f6964d92430303030303030302d303030302d343030302d383030302d303030303030303030303032

View file

@ -1 +1 @@
85ad736368656d6156657273696f6eb767616d6563756c742e666f726b2e7265636f72642e7630a7666f726b5f6964d930657572656b612d7375627374726174653a7175657374696f6e3a6465736b2d6c697374696e672d617574686f72697479ac6f7074696f6e735f68617368d94037643935666338376435333234323036313166653431356331646566323761333434373631376262363832333566343665336166313330616561333631633438b1636f756e7465645f616e737765725f6964a26e31a7616e737765727392de0010ad736368656d6156657273696f6eb767616d6563756c742e6465736b5f616e737765722e7630a9616e737765725f6964a26e31a7666f726b5f6964d930657572656b612d7375627374726174653a7175657374696f6e3a6465736b2d6c697374696e672d617574686f72697479a76f7574636f6d65a7436f756e746564a26f66c0a87265747261637473c0a4636f6465c0ac6f7074696f6e735f68617368d94037643935666338376435333234323036313166653431356331646566323761333434373631376262363832333566343665336166313330616561333631633438a663686f696365ab61736b696e672d6d696e64a46e6f7465be5468652061736b6572206c6973747320686572206f776e20666f726b732eab616e7377657265645f6174b4323032362d31312d31315431373a30303a30305aab72656365697665645f6174b4323032362d31312d31315431373a30303a30305aaf636c61696d5f696e5f667574757265c2a8616e737765726572a137a9617574686f72697479a64d656d626572aa726571756573745f6964d92430303030303030302d303030302d343030302d383030302d303030303030303030303031de0010ad736368656d6156657273696f6eb767616d6563756c742e6465736b5f616e737765722e7630a9616e737765725f6964a26e32a7666f726b5f6964d930657572656b612d7375627374726174653a7175657374696f6e3a6465736b2d6c697374696e672d617574686f72697479a76f7574636f6d65a85265766973696f6ea26f66a26e31a87265747261637473c0a4636f6465c0ac6f7074696f6e735f68617368d94037643935666338376435333234323036313166653431356331646566323761333434373631376262363832333566343665336166313330616561333631633438a663686f696365ab61736b696e672d6d696e64a46e6f7465a74167726565642eab616e7377657265645f6174b4323032362d31312d31315431373a30353a30305aab72656365697665645f6174b4323032362d31312d31315431373a30353a30305aaf636c61696d5f696e5f667574757265c2a8616e737765726572a23132a9617574686f72697479a64d656d626572aa726571756573745f6964d92430303030303030302d303030302d343030302d383030302d303030303030303030303032
85ad736368656d6156657273696f6eb767616d6563756c742e666f726b2e7265636f72642e7630a7666f726b5f6964d930657572656b612d7375627374726174653a7175657374696f6e3a6465736b2d6c697374696e672d617574686f72697479ac6f7074696f6e735f68617368d94037643935666338376435333234323036313166653431356331646566323761333434373631376262363832333566343665336166313330616561333631633438b1636f756e7465645f616e737765725f6964a26e31a7616e737765727392de0010ad736368656d6156657273696f6eb767616d6563756c742e6465736b5f616e737765722e7630a9616e737765725f6964a26e31a7666f726b5f6964d930657572656b612d7375627374726174653a7175657374696f6e3a6465736b2d6c697374696e672d617574686f72697479a76f7574636f6d65a7436f756e746564a26f66c0a87265747261637473c0a4636f6465c0ac6f7074696f6e735f68617368d94037643935666338376435333234323036313166653431356331646566323761333434373631376262363832333566343665336166313330616561333631633438a663686f696365ab61736b696e672d6d696e64a46e6f7465be5468652061736b6572206c6973747320686572206f776e20666f726b732eab616e7377657265645f6174b4323032362d31312d31315431373a30303a30305aab72656365697665645f6174b4323032362d31312d31315431373a30303a30305aaf636c61696d5f696e5f667574757265c2a8616e737765726572d92435663063326231652d386134642d346333622d396537662d316132623363346435653666a9617574686f72697479a64d656d626572aa726571756573745f6964d92430303030303030302d303030302d343030302d383030302d303030303030303030303031de0010ad736368656d6156657273696f6eb767616d6563756c742e6465736b5f616e737765722e7630a9616e737765725f6964a26e32a7666f726b5f6964d930657572656b612d7375627374726174653a7175657374696f6e3a6465736b2d6c697374696e672d617574686f72697479a76f7574636f6d65a85265766973696f6ea26f66a26e31a87265747261637473c0a4636f6465c0ac6f7074696f6e735f68617368d94037643935666338376435333234323036313166653431356331646566323761333434373631376262363832333566343665336166313330616561333631633438a663686f696365ab61736b696e672d6d696e64a46e6f7465a74167726565642eab616e7377657265645f6174b4323032362d31312d31315431373a30353a30305aab72656365697665645f6174b4323032362d31312d31315431373a30353a30305aaf636c61696d5f696e5f667574757265c2a8616e737765726572d92430623964376533612d366332312d346635382d613064342d396538663761366235633464a9617574686f72697479a64d656d626572aa726571756573745f6964d92430303030303030302d303030302d343030302d383030302d303030303030303030303032

File diff suppressed because one or more lines are too long

View file

@ -22,7 +22,7 @@ public static class DeskReplay
public static ForkEntry Entry(JsonElement card) => new(
"gamecult.fork.entry.v0",
card,
new ForkRecord("gamecult.fork.record.v0", card.GetProperty("fork_id").GetString()!, card.GetProperty("options_hash").GetString()!, null, []));
new ForkRecord("gamecult.fork.record.v0", card.GetProperty("fork_id").GetString()!, card.GetProperty("options_hash").GetString()!, null, 0, []));
// Every fork the vectors say each Mind holds, on that Mind's socket.
public static void HoldVectorForks(FakeDeskDoor door)

View file

@ -3,12 +3,12 @@ using System.Text.Json.Nodes;
namespace Bifrost.Web.Tests.Support;
// CultLib's fork-card vectors, vendored at commit de8a062ab9d8c510c8b36e634fae8f108a570aff.
// CultLib's fork-card vectors, vendored at commit 3a51bbabad244a56ec4521080530d88744001ce4 (#117 on af914253 #115, the final card contract).
public static class DeskVectors
{
public const string SourceCommit = "de8a062ab9d8c510c8b36e634fae8f108a570aff";
public const string SourceCommit = "3a51bbabad244a56ec4521080530d88744001ce4";
public const string FileSha256 = "a7129eee00cb38c602481b0de7de0182f83122685b69ff441e3123adc3e0f774";
public const string FileSha256 = "13afdcba1f45fd09eb433142c222d435b542cc891e0263df2da0c37ff522d39d";
public static string Path => System.IO.Path.Combine(AppContext.BaseDirectory, "Fixtures", "fork-card-vectors.json");

View file

@ -1,17 +1,22 @@
using System.Diagnostics;
using System.Net.Sockets;
using System.Text.Json;
using System.Text.Json.Nodes;
using MessagePack;
using Bifrost.Web.Features.Desk;
using Bifrost.Web.Tests.Support;
namespace Bifrost.Web.Tests;
// The production door against a real unix socket and Huginn's golden frames (fixtures at Huginn 9dde93e).
// The production door against a real unix socket and Huginn's golden frames (fixtures at Huginn 79d954c).
public sealed class UnixSocketDeskDoorTests
{
private const string Fork = "eureka-substrate:question:desk-listing-authority";
private static readonly DeskDoorContext Context = new("eureka", "Member", "7", ["7", "12"]);
// The fixtures' account ids: lowercase D-format UUIDs, synthetic.
private const string Decider = "5f0c2b1e-8a4d-4c3b-9e7f-1a2b3c4d5e6f";
private static readonly DeskDoorContext Context = new("eureka", "Member", Decider, [Decider, "0b9d7e3a-6c21-4f58-a0d4-9e8f7a6b5c4d"]);
private static UnixSocketDeskDoor DoorWith(string messageId) => new(() => messageId);
@ -203,7 +208,7 @@ public sealed class UnixSocketDeskDoorTests
"""{"order":8,"future_key":{"z":[3,null,100],"a":true},"options_hash":"cd","schemaVersion":"gamecult.fork.card.v0","fork_id":"x:question:b","title":"B","leans":null}""";
private static string EntryJson(string card, string forkId) =>
$$$"""{"schemaVersion":"gamecult.fork.entry.v0","card":{{{card}}},"record":{"schemaVersion":"gamecult.fork.record.v0","fork_id":"{{{forkId}}}","options_hash":"ab","counted_answer_id":null,"answers":[]}}""";
$$$"""{"schemaVersion":"gamecult.fork.entry.v0","card":{{{card}}},"record":{"schemaVersion":"gamecult.fork.record.v0","fork_id":"{{{forkId}}}","options_hash":"ab","counted_answer_id":null,"answerer_count":0,"answers":[]}}""";
[Fact]
public async Task Cards_in_a_list_and_a_read_come_through_byte_faithful()
@ -235,6 +240,145 @@ public sealed class UnixSocketDeskDoorTests
Assert.Equal((DeskSchemas.AnswerResult, "n1", "Counted", "n1", null), (result.SchemaVersion, result.Answer.AnswerId, result.Answer.Outcome, result.CountedAnswerId, result.Card));
}
// ---- (c2) both reader views through the door and the edge ----
// Huginn's fragments at 79d954c, as JSON. record-whole is the decider's view as Huginn sent it before
// answerer_count existed; record-non-decider.proposed is a PROPOSED mirror type built in Huginn's test (the
// non-decider view, every answerer nil, answerer_count 2); card-viewers-*.synthetic are SYNTHETIC two-key
// fragments, not cards. Bifrost reads none of them as anything but what they are: a record, and two keys a card
// carries.
private static JsonObject Fragment(string name) =>
JsonNode.Parse(MessagePackSerializer.ConvertToJson(File.ReadAllBytes(
Path.Combine(DeskFeedFixturePinTests.Directory, name + ".payload.msgpack"))))!.AsObject();
// The decider's view as the CultLib 3a51bbab contract spells it: record-whole with answerer_count (the number of
// distinct ids over its two answers) in the contract's place, after counted_answer_id. Huginn's record-whole does
// not carry it yet.
private static JsonObject DeciderRecord()
{
var whole = Fragment("record-whole");
var record = new JsonObject();
foreach (var (key, value) in whole.ToList())
{
whole.Remove(key);
record[key] = value;
if (key == "counted_answer_id")
{
record["answerer_count"] = 2;
}
}
return record;
}
// The vector card with its two reader-view keys replaced by a fragment's, in the card's own key order.
private static string ViewCard(string fragment)
{
var card = JsonNode.Parse(DeskVectors.Rows("card", "valid").First(r => (string)r["name"]! == "operator_fork")["message"]!.ToJsonString())!.AsObject();
var view = Fragment(fragment);
card["fork_id"] = Fork;
card["deciders"] = view["deciders"]!.DeepClone();
card["decider_count"] = view["decider_count"]!.DeepClone();
return card.ToJsonString(DeskJson.Options);
}
private static string EntryOf(string card, JsonObject record) =>
$$$"""{"schemaVersion":"gamecult.fork.entry.v0","card":{{{card}}},"record":{{{record.ToJsonString(DeskJson.Options)}}}}""";
private static string ListOf(string entry) =>
$$$"""{"Forks":{"list":{"schemaVersion":"gamecult.fork.list.v0","mind":"gamecult-chat","stamp":"s7","open_count":1,"recorded_count":0,"forks":[{{{entry}}}],"next_cursor":null},"as_of":7}}""";
[Fact]
public void Every_account_id_in_the_fixtures_is_a_lowercase_D_format_uuid_and_the_non_decider_fragments_name_none()
{
var grammar = new System.Text.RegularExpressions.Regex("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$");
foreach (var id in Fragment("card-viewers-decider.synthetic")["deciders"]!.AsArray().Select(d => (string)d!)
.Concat(Fragment("record-whole")["answers"]!.AsArray().Select(a => (string)a!["answerer"]!)))
{
Assert.Matches(grammar, id);
}
var nonDeciderCard = Fragment("card-viewers-non-decider.synthetic");
Assert.Empty(nonDeciderCard["deciders"]!.AsArray());
Assert.Equal(2, (int)nonDeciderCard["decider_count"]!);
Assert.All(Fragment("record-non-decider.proposed")["answers"]!.AsArray(), a => Assert.Null(a!["answerer"]));
}
[Theory]
[InlineData("card-viewers-decider.synthetic")]
[InlineData("card-viewers-non-decider.synthetic")]
public async Task A_card_in_either_view_comes_through_the_door_byte_for_byte(string view)
{
var card = ViewCard(view);
var nonDecider = view.Contains("non-decider", StringComparison.Ordinal);
var record = nonDecider ? Fragment("record-non-decider.proposed") : DeciderRecord();
using var huginn = new FakeHuginnSocket(FakeHuginnSocket.Answer((_, _) => ListOf(EntryOf(card, record))));
var listed = Assert.IsType<DeskListOutcome.Listed>(await List(new UnixSocketDeskDoor(), huginn.Path));
var entry = Assert.Single(listed.List.Forks);
// The card is opaque: raised_at (a string), decider_count and the withheld or whole deciders leave as they came.
Assert.Equal(card, JsonSerializer.Serialize(entry.Card, DeskJson.Options));
Assert.Equal(nonDecider, entry.Card.GetProperty("deciders").GetArrayLength() == 0);
Assert.Equal(2, entry.Card.GetProperty("decider_count").GetInt32());
Assert.Equal(JsonValueKind.String, entry.Card.GetProperty("raised_at").ValueKind);
Assert.Equal(2, entry.Record.AnswererCount);
Assert.Equal(record.ToJsonString(DeskJson.Options), JsonSerializer.Serialize(entry.Record, DeskJson.Options));
Assert.All(entry.Record.Answers, a => Assert.Equal(nonDecider, a.Answerer is null));
}
[Fact]
public async Task A_decider_record_keeps_its_ids_and_a_non_decider_record_comes_through_with_nil_answerers_and_the_count()
{
var chat = DeskWebApplicationFactory.SocketOf("gamecult-chat");
_ = chat; // the edge below talks to a real socket, not the fake door's table
var nonDecider = Fragment("record-non-decider.proposed");
using var huginn = new FakeHuginnSocket(FakeHuginnSocket.Answer((_, _) => ListOf(EntryOf(ViewCard("card-viewers-non-decider.synthetic"), nonDecider))));
using var factory = new DeskWebApplicationFactory(ConfigurationWith(huginn.Path, FakeHuginnSocket.Absent()), fakeDoor: false);
await factory.EnsureAccountAsync(DeskWebApplicationFactory.Member, true);
var reply = await factory.SendAsync("GET", "/api/desk/gamecult-chat/forks", token: factory.Token(DeskWebApplicationFactory.Member, "bifrost-desk", "desk.read"));
// Huginn withheld the ids; Bifrost invents none, and nils the notes (the one thing it strips).
Assert.Equal(200, reply.Status);
var forks = JsonNode.Parse(reply.Text)!["forks"]!.AsArray();
var record = forks[0]!["record"]!;
Assert.Equal(2, (int)record["answerer_count"]!);
Assert.All(record["answers"]!.AsArray(), a =>
{
Assert.True(a!.AsObject().ContainsKey("answerer"));
Assert.Null(a["answerer"]);
Assert.Null(a["note"]);
});
Assert.Empty(forks[0]!["card"]!["deciders"]!.AsArray());
Assert.Equal(2, (int)forks[0]!["card"]!["decider_count"]!);
Assert.DoesNotContain("The asker lists her own forks.", reply.Text);
// The decider's view, as the contract spells it, keeps every id and every note.
var decider = DeciderRecord();
using var huginn2 = new FakeHuginnSocket(FakeHuginnSocket.Answer((_, _) => ListOf(EntryOf(ViewCard("card-viewers-decider.synthetic"), decider))));
using var factory2 = new DeskWebApplicationFactory(ConfigurationWith(huginn2.Path, FakeHuginnSocket.Absent()), fakeDoor: false);
await factory2.EnsureAccountAsync(DeskWebApplicationFactory.Alice, true);
var own = await factory2.SendAsync("GET", "/api/desk/gamecult-chat/forks", token: factory2.Token(DeskWebApplicationFactory.Alice, "bifrost-desk", "desk.read"));
Assert.Equal(200, own.Status);
var shown = JsonNode.Parse(own.Text)!["forks"]![0]!["record"]!;
Assert.Equal(decider.ToJsonString(DeskJson.Options), shown.ToJsonString(DeskJson.Options));
}
// Huginn's record-whole at 79d954c has no answerer_count, which the 3a51bbab contract requires. The door refuses it
// as a reply that does not decode; it does not write the 0 it could have made up. When Huginn's fixture gains the
// key this test is the one to retire.
[Fact]
public async Task Huginns_record_without_answerer_count_is_a_fault_not_a_zero()
{
var entry = EntryOf(ViewCard("card-viewers-decider.synthetic"), Fragment("record-whole"));
using var huginn = new FakeHuginnSocket(FakeHuginnSocket.Answer((_, _) => ListOf(entry)));
var failure = await Assert.ThrowsAsync<DeskDoorException>(() => List(new UnixSocketDeskDoor(), huginn.Path));
Assert.Contains("does not decode", failure.Message);
}
// ---- (d) one dead Mind fails only itself, through the HTTP edge ----
private static Dictionary<string, string?> ConfigurationWith(string chatSocket, string nibuSocket)