From a2c41b1f34e3cb585af90cd2e3d096d342d6a947 Mon Sep 17 00:00:00 2001 From: Heimdall Date: Wed, 11 Nov 2026 19:14:17 +0000 Subject: [PATCH] Desk: re-vendor Huginn desk fixtures at b299d6f7 (71 files, CultLib 3a51bbab subdirectory) and CultLib vectors at d3025d3c Pins name the commits, the exact file list and each sha256; the verifier is proved to fail on a changed byte, an extra file and a missing file, at both directory levels. The four golden request frames still reproduce. The synthetic card-viewers and proposed non-decider fragments are gone: both reader views are now CultLib's own entry bytes served through the door. Huginn's record-whole still has no answerer_count (its README says so), so the fault test stays true and is re-pointed at it. Co-Authored-By: Claude Sonnet 5.5 --- .../Bifrost.Web.Tests.csproj | 2 +- .../DeskFeedFixturePinTests.cs | 133 ++- tests/Bifrost.Web.Tests/DeskReadTests.cs | 2 +- .../Bifrost.Web.Tests/DeskReaderViewTests.cs | 9 +- tests/Bifrost.Web.Tests/DeskVectorPinTests.cs | 3 +- .../Fixtures/desk-feed/README.md | 12 +- ...card-viewers-decider.synthetic.payload.hex | 1 - ...-viewers-decider.synthetic.payload.msgpack | 1 - ...-viewers-non-decider.synthetic.payload.hex | 1 - ...wers-non-decider.synthetic.payload.msgpack | 1 - .../desk-feed/cultlib-3a51bbab/README.md | 26 + .../cultlib-3a51bbab/answer-counted.msgpack | Bin 0 -> 516 bytes .../answer-refused-stale.msgpack | Bin 0 -> 526 bytes .../answer-retraction.msgpack | Bin 0 -> 436 bytes .../cultlib-3a51bbab/answer-revision.msgpack | Bin 0 -> 461 bytes .../answer-withheld-answerer.msgpack | Bin 0 -> 479 bytes .../card-operator-fork.msgpack | Bin 0 -> 577 bytes .../card-raised-at-nil.msgpack | Bin 0 -> 557 bytes .../card-withheld-deciders.msgpack | Bin 0 -> 539 bytes ...y-closed-with-ruling-and-a-refusal.msgpack | Bin 0 -> 1853 bytes .../entry-open-counted.msgpack | Bin 0 -> 1298 bytes ...d-closed-with-ruling-and-a-refusal.msgpack | Bin 0 -> 1741 bytes .../entry-withheld-open-counted.msgpack | Bin 0 -> 1223 bytes .../record-non-decider.proposed.payload.hex | 1 - ...ecord-non-decider.proposed.payload.msgpack | Bin 1084 -> 0 bytes .../desk-feed/record-whole.payload.hex | 2 +- .../desk-feed/record-whole.payload.msgpack | Bin 1142 -> 2052 bytes .../Fixtures/fork-card-vectors.json | 982 ++++++++++++++++++ tests/Bifrost.Web.Tests/Support/DeskServe.cs | 82 ++ .../Bifrost.Web.Tests/Support/DeskVectors.cs | 7 +- .../UnixSocketDeskDoorTests.cs | 210 ++-- 31 files changed, 1337 insertions(+), 138 deletions(-) delete mode 100644 tests/Bifrost.Web.Tests/Fixtures/desk-feed/card-viewers-decider.synthetic.payload.hex delete mode 100644 tests/Bifrost.Web.Tests/Fixtures/desk-feed/card-viewers-decider.synthetic.payload.msgpack delete mode 100644 tests/Bifrost.Web.Tests/Fixtures/desk-feed/card-viewers-non-decider.synthetic.payload.hex delete mode 100644 tests/Bifrost.Web.Tests/Fixtures/desk-feed/card-viewers-non-decider.synthetic.payload.msgpack create mode 100644 tests/Bifrost.Web.Tests/Fixtures/desk-feed/cultlib-3a51bbab/README.md create mode 100644 tests/Bifrost.Web.Tests/Fixtures/desk-feed/cultlib-3a51bbab/answer-counted.msgpack create mode 100644 tests/Bifrost.Web.Tests/Fixtures/desk-feed/cultlib-3a51bbab/answer-refused-stale.msgpack create mode 100644 tests/Bifrost.Web.Tests/Fixtures/desk-feed/cultlib-3a51bbab/answer-retraction.msgpack create mode 100644 tests/Bifrost.Web.Tests/Fixtures/desk-feed/cultlib-3a51bbab/answer-revision.msgpack create mode 100644 tests/Bifrost.Web.Tests/Fixtures/desk-feed/cultlib-3a51bbab/answer-withheld-answerer.msgpack create mode 100644 tests/Bifrost.Web.Tests/Fixtures/desk-feed/cultlib-3a51bbab/card-operator-fork.msgpack create mode 100644 tests/Bifrost.Web.Tests/Fixtures/desk-feed/cultlib-3a51bbab/card-raised-at-nil.msgpack create mode 100644 tests/Bifrost.Web.Tests/Fixtures/desk-feed/cultlib-3a51bbab/card-withheld-deciders.msgpack create mode 100644 tests/Bifrost.Web.Tests/Fixtures/desk-feed/cultlib-3a51bbab/entry-closed-with-ruling-and-a-refusal.msgpack create mode 100644 tests/Bifrost.Web.Tests/Fixtures/desk-feed/cultlib-3a51bbab/entry-open-counted.msgpack create mode 100644 tests/Bifrost.Web.Tests/Fixtures/desk-feed/cultlib-3a51bbab/entry-withheld-closed-with-ruling-and-a-refusal.msgpack create mode 100644 tests/Bifrost.Web.Tests/Fixtures/desk-feed/cultlib-3a51bbab/entry-withheld-open-counted.msgpack delete mode 100644 tests/Bifrost.Web.Tests/Fixtures/desk-feed/record-non-decider.proposed.payload.hex delete mode 100644 tests/Bifrost.Web.Tests/Fixtures/desk-feed/record-non-decider.proposed.payload.msgpack create mode 100644 tests/Bifrost.Web.Tests/Support/DeskServe.cs diff --git a/tests/Bifrost.Web.Tests/Bifrost.Web.Tests.csproj b/tests/Bifrost.Web.Tests/Bifrost.Web.Tests.csproj index c9c0497..77b9003 100644 --- a/tests/Bifrost.Web.Tests/Bifrost.Web.Tests.csproj +++ b/tests/Bifrost.Web.Tests/Bifrost.Web.Tests.csproj @@ -23,7 +23,7 @@ - + diff --git a/tests/Bifrost.Web.Tests/DeskFeedFixturePinTests.cs b/tests/Bifrost.Web.Tests/DeskFeedFixturePinTests.cs index ce37a62..e139ccd 100644 --- a/tests/Bifrost.Web.Tests/DeskFeedFixturePinTests.cs +++ b/tests/Bifrost.Web.Tests/DeskFeedFixturePinTests.cs @@ -2,29 +2,39 @@ 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 79d954c (docs/desk-feed-door.md is the contract). +// Huginn's desk-feed golden bytes, vendored byte for byte from crates/huginn-mind/tests/fixtures/desk-feed/ at Huginn +// main b299d6f7320cd0879c93d5cc1d1adb0dbed7339b (#58; docs/desk-feed-door.md is the contract): 71 files, the +// subdirectory cultlib-3a51bbab/ (twelve CultLib vectors, unedited) included. The pin is the exact file list and each +// sha256; a changed byte, an extra file or a missing file fails, and the verifier is proved to catch each. // 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 = "79d954c"; + public const string HuginnCommit = "b299d6f7320cd0879c93d5cc1d1adb0dbed7339b"; public static readonly string Directory = Path.Combine(AppContext.BaseDirectory, "Fixtures", "desk-feed"); - private static readonly Dictionary Sha256 = new(StringComparer.Ordinal) + public static readonly IReadOnlyDictionary Sha256 = new Dictionary(StringComparer.Ordinal) { - [".gitattributes"] = "171872d6445cb1ffef0263b613d1ac318a60398449831d4cc4f772f78a7ebcff", - ["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", + ["cultlib-3a51bbab/answer-counted.msgpack"] = "55d69ae3cc7ebbeeae7d501e8641640e115c3fb5aac399ea760588bca343b9e6", + ["cultlib-3a51bbab/answer-refused-stale.msgpack"] = "3183bc9c483f4a625332cda11ef22a9c8560868a7728b77daa63a1960a3cd3d6", + ["cultlib-3a51bbab/answer-retraction.msgpack"] = "89156f41ec3ea54f5d47bd3318913ff013785f4727916875be97785935cb7735", + ["cultlib-3a51bbab/answer-revision.msgpack"] = "19d7289395ae68cbaf6de1c0a1ef6c843211b2caf9462e1d2268cd0883386315", + ["cultlib-3a51bbab/answer-withheld-answerer.msgpack"] = "b66b4f921cdd374be04af3de34c59e254a5e542027ae8c57f196a3ea3406e427", + ["cultlib-3a51bbab/card-operator-fork.msgpack"] = "56bfdb65ded60b562001d09d0b8da6e092900f404bf5f68f7084dff29bcc34f5", + ["cultlib-3a51bbab/card-raised-at-nil.msgpack"] = "b81bb825790ffe03fabe63c3f8a61c36bd50ca268aa6dff67b5bcfad3957e58c", + ["cultlib-3a51bbab/card-withheld-deciders.msgpack"] = "d13b9b77461cfdf78f943ef56c6aeab852ab6b6f0b355e26c5b361f99c79c7f7", + ["cultlib-3a51bbab/entry-closed-with-ruling-and-a-refusal.msgpack"] = "f7859c7d04d338d6b1c634308b08ae58ae77b0ff459767859a5e40f0af2f16e5", + ["cultlib-3a51bbab/entry-open-counted.msgpack"] = "b51f499e8dd0465cf5df9d68d8fccbe94dd1339fd3157969693dd0d4ecb2549b", + ["cultlib-3a51bbab/entry-withheld-closed-with-ruling-and-a-refusal.msgpack"] = "daaa819bfa2612616826ef3217dfcf8d8d8cb71d86547d7106426c779134f827", + ["cultlib-3a51bbab/entry-withheld-open-counted.msgpack"] = "62ccad7a9f41262d6e35d0247315d0bb75d1313b3c9dabe8a99d1aa1b844607f", + ["cultlib-3a51bbab/README.md"] = "9262509aab2cb3c3dbdbb4994a959669685cac0fff0f927b790da769787cc42b", ["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", + [".gitattributes"] = "171872d6445cb1ffef0263b613d1ac318a60398449831d4cc4f772f78a7ebcff", ["list-counts.request.frame.bin"] = "be338fc06f127f9c20f82952708ffe95f8b6b8de7c5098834eb8cb257893637f", ["list-counts.request.frame.hex"] = "496bbc58292a1d029361bd553eef2ccf786cfa6520b1a3ad97c831893c36cf50", ["list-counts.request.payload.hex"] = "5ec076a5d8006a0290ad269deffb2bfe45ac7ee8b6a11ea2d4968a6ac8603e4b", @@ -53,6 +63,11 @@ public sealed class DeskFeedFixturePinTests ["list-too-large.response.frame.hex"] = "aad762b1e1deea39330223eb9ea7ebd2bb0fdd3326e259383b90846c1310456f", ["list-too-large.response.payload.hex"] = "880ae2c51454a3d6b06d2e827e44b6990365d8cfa304b55e25eb898641117762", ["list-too-large.response.payload.msgpack"] = "710d145c1ded7e7d02343342becd61e4520da979580f13dbebe6f0eda5aabec6", + ["README.md"] = "67158e6a566ad03e648c317d751ca59e6ea125daef56f60f5288bef1f8142ca1", + ["read.request.frame.bin"] = "3a9bc16ce4ce706e8c839bf4cfe65d3e2fdf759992555e68be6fc7bcc15653ea", + ["read.request.frame.hex"] = "3c3d9540c4af789d230b7108f98d5d5f3dd9b291ff618064ddc374eb2a7bb082", + ["read.request.payload.hex"] = "48aed263254eac7bc156c1af1f2ee210a08dda2b453a5be2dc17083ab73800b2", + ["read.request.payload.msgpack"] = "c5447f462247703af4329e071bc0ac14dce1cb94a63c85517400791d022263ca", ["read-too-large.response.frame.bin"] = "5995c03914851ea95aaff4b75fa3ebaee4f19a2c7ce101eab85b7475515690bd", ["read-too-large.response.frame.hex"] = "b150aa192bf3fa415b5175f8b9f43731c5b73c2a2153c87da2dc3a4b6d986ee2", ["read-too-large.response.payload.hex"] = "18b7ad6c617ee1d9a3aa726a012e9a3af8ca9c14b8af774d082cf17879c85b90", @@ -61,14 +76,8 @@ 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"] = "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", + ["record-whole.payload.hex"] = "bf2530550ff5d2a7bf5c650e9af9d73dc8bcd4e4328fdc797ae6167b9e3d1a25", + ["record-whole.payload.msgpack"] = "07f2687e9e9f169dded3e61c645fcd6d0a766f64a2b9d469eabb7ae98c6e254f", ["refused-unit.response.frame.bin"] = "4f86943a6947dd3c6041ee7d1b52d3f73697604dd224ca5dcf5b66064b0de1f1", ["refused-unit.response.frame.hex"] = "f25f35911d242d6fdb7ac4e1ecb3fe01901aa4b816d957104bde6f21b29a1bed", ["refused-unit.response.payload.hex"] = "858d49c8c66ce1b9c32160e2aecb320a8c00166728c80f5a02d62ec90b4f410d", @@ -79,19 +88,85 @@ public sealed class DeskFeedFixturePinTests ["unavailable.response.payload.msgpack"] = "dfa613abaf5f23e6aff5bcb0a59b3a1784f2fbf6d12cbdfa82f10e80963f0a4e", }; - [Fact] - public void Fixtures_are_huginn_79d954c_byte_for_byte() + // Every way the directory differs from the pin, by relative path (forward slashes). + public static List Problems(string directory) { - var present = new DirectoryInfo(Directory).GetFiles().Select(f => f.Name).Order(StringComparer.Ordinal).ToArray(); - Assert.Equal(Sha256.Keys.Order(StringComparer.Ordinal).ToArray(), present); - - foreach (var (name, expected) in Sha256) + var present = new Dictionary(StringComparer.Ordinal); + foreach (var file in new DirectoryInfo(directory).EnumerateFiles("*", SearchOption.AllDirectories)) { - var actual = Convert.ToHexString(SHA256.HashData(File.ReadAllBytes(Path.Combine(Directory, name)))).ToLowerInvariant(); - Assert.True( - expected == actual, - $"{name} is not Huginn {HuginnCommit}:crates/huginn-mind/tests/fixtures/desk-feed/{name} (sha256 {actual}). " + - "Re-vendor from that commit or move the pin on purpose."); + var name = Path.GetRelativePath(directory, file.FullName).Replace('\\', '/'); + present[name] = Convert.ToHexString(SHA256.HashData(File.ReadAllBytes(file.FullName))).ToLowerInvariant(); + } + + var problems = new List(); + problems.AddRange(Sha256.Keys.Except(present.Keys, StringComparer.Ordinal).Order(StringComparer.Ordinal).Select(n => $"missing: {n}")); + problems.AddRange(present.Keys.Except(Sha256.Keys, StringComparer.Ordinal).Order(StringComparer.Ordinal).Select(n => $"extra: {n}")); + problems.AddRange(Sha256.Where(p => present.TryGetValue(p.Key, out var actual) && actual != p.Value).Select(p => $"changed: {p.Key}")); + return problems; + } + + [Fact] + public void Fixtures_are_huginn_b299d6f7_byte_for_byte() + { + Assert.Equal(71, Sha256.Count); + Assert.True(Problems(Directory).Count == 0, + $"not Huginn {HuginnCommit}:crates/huginn-mind/tests/fixtures/desk-feed/: {string.Join("; ", Problems(Directory))}. " + + "Re-vendor from that commit or move the pin on purpose."); + } + + private static string Copy() + { + var copy = System.IO.Directory.CreateTempSubdirectory("pin").FullName; + foreach (var file in new DirectoryInfo(Directory).EnumerateFiles("*", SearchOption.AllDirectories)) + { + var to = Path.Combine(copy, Path.GetRelativePath(Directory, file.FullName)); + System.IO.Directory.CreateDirectory(Path.GetDirectoryName(to)!); + file.CopyTo(to); + } + + return copy; + } + + [Theory] + [InlineData("list-open.request.frame.bin", "changed")] + [InlineData("cultlib-3a51bbab/entry-open-counted.msgpack", "changed")] + [InlineData("README.md", "changed")] + public void A_changed_byte_fails_the_pin(string name, string kind) + { + var copy = Copy(); + try + { + var path = Path.Combine(copy, name); + var bytes = File.ReadAllBytes(path); + bytes[^1] ^= 1; + File.WriteAllBytes(path, bytes); + + Assert.Equal([$"{kind}: {name}"], Problems(copy)); + } + finally + { + System.IO.Directory.Delete(copy, true); + } + } + + [Fact] + public void An_extra_or_missing_file_fails_the_pin_at_either_level() + { + var copy = Copy(); + try + { + File.WriteAllText(Path.Combine(copy, "extra.hex"), "00\n"); + File.WriteAllText(Path.Combine(copy, "cultlib-3a51bbab", "extra.msgpack"), "x"); + File.Delete(Path.Combine(copy, "read.request.frame.hex")); + File.Delete(Path.Combine(copy, "cultlib-3a51bbab", "answer-counted.msgpack")); + + Assert.Equal( + ["missing: cultlib-3a51bbab/answer-counted.msgpack", "missing: read.request.frame.hex", "extra: cultlib-3a51bbab/extra.msgpack", "extra: extra.hex"], + Problems(copy)); + } + finally + { + System.IO.Directory.Delete(copy, true); } } } diff --git a/tests/Bifrost.Web.Tests/DeskReadTests.cs b/tests/Bifrost.Web.Tests/DeskReadTests.cs index 68e9eab..2668724 100644 --- a/tests/Bifrost.Web.Tests/DeskReadTests.cs +++ b/tests/Bifrost.Web.Tests/DeskReadTests.cs @@ -102,7 +102,7 @@ public sealed class DeskReadTests } } - Assert.Equal(10, steps); + Assert.Equal(12, steps); } [Fact] diff --git a/tests/Bifrost.Web.Tests/DeskReaderViewTests.cs b/tests/Bifrost.Web.Tests/DeskReaderViewTests.cs index cd5ae81..88766c7 100644 --- a/tests/Bifrost.Web.Tests/DeskReaderViewTests.cs +++ b/tests/Bifrost.Web.Tests/DeskReaderViewTests.cs @@ -5,7 +5,7 @@ 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, +// CultLib d3025d3c's reader views (append-only on 3a51bbab), 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 { @@ -43,6 +43,7 @@ public sealed class DeskReaderViewTests public void The_options_hash_vectors_are_the_15_and_Bifrost_computes_no_hash() { Assert.Equal(15, DeskVectors.Array("optionsHash").Count); + Assert.Equal(9, DeskVectors.Array("bodyDigests").Count); var directory = new DirectoryInfo(AppContext.BaseDirectory); while (directory is not null && !Directory.Exists(Path.Combine(directory.FullName, "src", "Bifrost.Web", "Features", "Desk"))) { @@ -62,8 +63,10 @@ public sealed class DeskReaderViewTests 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.Equal(8, rows.Count); Assert.Contains(rows, r => (string)r["name"]! == "withheld_answerer"); + Assert.Contains(rows, r => (string)r["name"]! == "withheld_answerer_revision" && (string)r["message"]!["outcome"]! == "Revision"); + Assert.Contains(rows, r => (string)r["name"]! == "withheld_answerer_retraction" && (string)r["message"]!["outcome"]! == "Retraction"); var outcomes = new HashSet(); foreach (var row in rows) { @@ -87,7 +90,7 @@ public sealed class DeskReaderViewTests 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); + Assert.Equal(8, valid.Count); foreach (var row in valid) { var message = row["message"]!; diff --git a/tests/Bifrost.Web.Tests/DeskVectorPinTests.cs b/tests/Bifrost.Web.Tests/DeskVectorPinTests.cs index c759371..64e7df2 100644 --- a/tests/Bifrost.Web.Tests/DeskVectorPinTests.cs +++ b/tests/Bifrost.Web.Tests/DeskVectorPinTests.cs @@ -6,8 +6,9 @@ namespace Bifrost.Web.Tests; public sealed class DeskVectorPinTests { [Fact] - public void Vectors_are_cultlib_3a51bbab() + public void Vectors_are_cultlib_d3025d3c() { + Assert.StartsWith("d3025d3c", DeskVectors.SourceCommit, StringComparison.Ordinal); var sha = Convert.ToHexString(SHA256.HashData(File.ReadAllBytes(DeskVectors.Path))).ToLowerInvariant(); Assert.True( diff --git a/tests/Bifrost.Web.Tests/Fixtures/desk-feed/README.md b/tests/Bifrost.Web.Tests/Fixtures/desk-feed/README.md index 0525883..4b98b4f 100644 --- a/tests/Bifrost.Web.Tests/Fixtures/desk-feed/README.md +++ b/tests/Bifrost.Web.Tests/Fixtures/desk-feed/README.md @@ -35,10 +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 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 | +| `record-whole` | fragment | `gamecult.fork.record.v0` with all four answer variants (Counted, Revision, Refused, Retraction) by three accounts, answerer ids and notes whole: what the door sends today (5 keys, no `answerer_count`) | -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. +The reader-count shapes (`raised_at`, `decider_count`, `answerer_count`, nullable `answerer`) are +CultLib's own bytes, vendored unedited in `cultlib-3a51bbab/` (see its README for the pinned commit and +each vector). They are not Huginn's output: Huginn's types do not carry those shapes yet. +`cut-desk-feed-listing` and `cut-desk-feed-raised-at` replace them with entry-bearing fixtures the +encoders write, after decoding these bytes into the real types. diff --git a/tests/Bifrost.Web.Tests/Fixtures/desk-feed/card-viewers-decider.synthetic.payload.hex b/tests/Bifrost.Web.Tests/Fixtures/desk-feed/card-viewers-decider.synthetic.payload.hex deleted file mode 100644 index 1624ae5..0000000 --- a/tests/Bifrost.Web.Tests/Fixtures/desk-feed/card-viewers-decider.synthetic.payload.hex +++ /dev/null @@ -1 +0,0 @@ -82a8646563696465727392d92435663063326231652d386134642d346333622d396537662d316132623363346435653666d92430623964376533612d366332312d346635382d613064342d396538663761366235633464ad646563696465725f636f756e7402 diff --git a/tests/Bifrost.Web.Tests/Fixtures/desk-feed/card-viewers-decider.synthetic.payload.msgpack b/tests/Bifrost.Web.Tests/Fixtures/desk-feed/card-viewers-decider.synthetic.payload.msgpack deleted file mode 100644 index 71b15b3..0000000 --- a/tests/Bifrost.Web.Tests/Fixtures/desk-feed/card-viewers-decider.synthetic.payload.msgpack +++ /dev/null @@ -1 +0,0 @@ -‚¨deciders’Ù$5f0c2b1e-8a4d-4c3b-9e7f-1a2b3c4d5e6fÙ$0b9d7e3a-6c21-4f58-a0d4-9e8f7a6b5c4d­decider_count \ No newline at end of file diff --git a/tests/Bifrost.Web.Tests/Fixtures/desk-feed/card-viewers-non-decider.synthetic.payload.hex b/tests/Bifrost.Web.Tests/Fixtures/desk-feed/card-viewers-non-decider.synthetic.payload.hex deleted file mode 100644 index 29a1257..0000000 --- a/tests/Bifrost.Web.Tests/Fixtures/desk-feed/card-viewers-non-decider.synthetic.payload.hex +++ /dev/null @@ -1 +0,0 @@ -82a8646563696465727390ad646563696465725f636f756e7402 diff --git a/tests/Bifrost.Web.Tests/Fixtures/desk-feed/card-viewers-non-decider.synthetic.payload.msgpack b/tests/Bifrost.Web.Tests/Fixtures/desk-feed/card-viewers-non-decider.synthetic.payload.msgpack deleted file mode 100644 index 252f158..0000000 --- a/tests/Bifrost.Web.Tests/Fixtures/desk-feed/card-viewers-non-decider.synthetic.payload.msgpack +++ /dev/null @@ -1 +0,0 @@ -‚¨deciders�­decider_count \ No newline at end of file diff --git a/tests/Bifrost.Web.Tests/Fixtures/desk-feed/cultlib-3a51bbab/README.md b/tests/Bifrost.Web.Tests/Fixtures/desk-feed/cultlib-3a51bbab/README.md new file mode 100644 index 0000000..a3203a7 --- /dev/null +++ b/tests/Bifrost.Web.Tests/Fixtures/desk-feed/cultlib-3a51bbab/README.md @@ -0,0 +1,26 @@ +# CultLib desk-feed vectors, vendored + +Source: `GameCult/CultLib` at commit `3a51bbabad244a56ec4521080530d88744001ce4` (#117, on +`af914253` #115), file `contracts/cultnet/governance/fork-card-vectors.json`. Each `.msgpack` file is +the vector's `messagePackHex` decoded to bytes, nothing else changed. Do not edit them or rewrite them +from Huginn's encoders: Huginn's own types do not carry these shapes yet (see +`docs/desk-feed-door.md`). To re-pin, take the new commit's vectors and update the sha here, in +`docs/desk-feed-door.md` and in `CULTLIB_SHA` in `desk_feed_fixtures.rs`. + +| file | upstream vector | what it pins | +|---|---|---| +| `card-operator-fork` | `card.valid` `operator_fork` | 18 keys (`DE 00 12`), `raised_at` a string, a decider's `deciders` and `decider_count` 1 | +| `card-raised-at-nil` | `card.valid` `raised_at_nil` | `raised_at` nil, key kept | +| `card-withheld-deciders` | `card.valid` `withheld_deciders` | empty `deciders`, `decider_count` 2 | +| `answer-counted` | `deskAnswer.valid` `counted` | 16 keys (`DE 00 10`), `answerer` a string | +| `answer-revision` | `deskAnswer.valid` `revision` | a `Revision`, `answerer` a string (no CultLib vector nulls a Revision) | +| `answer-retraction` | `deskAnswer.valid` `retraction` | a `Retraction`, `answerer` a string (no CultLib vector nulls a Retraction) | +| `answer-withheld-answerer` | `deskAnswer.valid` `withheld_answerer` | `answerer` nil | +| `answer-refused-stale` | `deskAnswer.valid` `refused_stale` | a `Refused` answer, `answerer` a string | +| `entry-open-counted` | `transport.entry.valid` `open_counted` | decider view: entry `83`, record `86`, `answerer_count` 1 | +| `entry-withheld-open-counted` | `transport.entry.valid` `withheld_open_counted` | non-decider twin: `deciders` empty, `answerer` nil, count 1 | +| `entry-closed-with-ruling-and-a-refusal` | `transport.entry.valid` `closed_with_ruling_and_a_refusal` | decider view, a refusal among the answers, `answerer_count` 2 | +| `entry-withheld-closed-with-ruling-and-a-refusal` | `transport.entry.valid` `withheld_closed_with_ruling_and_a_refusal` | its non-decider twin, count 2 | + +The test `desk_feed_fixtures.rs` checks each file's SHA-256, decodes it with a decoder of its own +(not `rmp_serde`), and then tries Huginn's real types. diff --git a/tests/Bifrost.Web.Tests/Fixtures/desk-feed/cultlib-3a51bbab/answer-counted.msgpack b/tests/Bifrost.Web.Tests/Fixtures/desk-feed/cultlib-3a51bbab/answer-counted.msgpack new file mode 100644 index 0000000000000000000000000000000000000000..332a9791fd2eab47b37ae366e02d0912dbd949fb GIT binary patch literal 516 zcmZ{hy^a$x5XX509>K*)P~gb+dOxxi5+wx^LKN4mCga&#E4y~Ey@z<6=tOcHhz5x^ z;w{qfEUd{)p>Am+Bo{eCkR`P-bHfh;OB&XqQfgcyF_O1`_nN{3V$;NlW>Yn)D0^K|0lh2) z5EPX}-F(KuTco}7cg`m|zkN-#V>YqTBaAHrmR+*!lG(`8Kn&(I`0y;U1sGp2aE8SJ zf^|1pw?K=Ab`T&fET+}N-Y>PMvjK zKc_j+ujAv&aK0j8B&topL9a`$tET2nQ?Gdi1jS5XX509>GN?%1yv`}&E(wSRDQ(1C zT*I@l&Oyl(^CA7_ufJw~zj*mQ;7BukBp-~kkJm60E>qkn3fmrR_)LCtBks;!Z`9t( zgLZzqwx`$sXpSSq?$bgct|DEST;wzOEk|bq*?4eEL^spnlJpWt?VWx)dWs$}hNoL} zita;%iTWh{&Fzv*=tl_S>8&h=M(aThm6W1V1ByyltMHW3SWR3avY|0}pX!F>W5t=ONWY{F#ZY;!<*%eUNP@vQCJr2Tw@m=6^tW^#dm` zb8l>~m$-QPb^I&oPZuPV#B9hp6m7|is;PO?)Ge=|916@;MpECMEt~k|_Owq6p7T_Bky4XV8qbmEe*iwRyfgp+ literal 0 HcmV?d00001 diff --git a/tests/Bifrost.Web.Tests/Fixtures/desk-feed/cultlib-3a51bbab/answer-retraction.msgpack b/tests/Bifrost.Web.Tests/Fixtures/desk-feed/cultlib-3a51bbab/answer-retraction.msgpack new file mode 100644 index 0000000000000000000000000000000000000000..7f2fb22cb08d654a5665ed6354832bb8b0597102 GIT binary patch literal 436 zcmZutJ5Iwu6yyjTA_dJx`}4Qr21p1|q_LiN-(oAVH|(y1xK0$2ABYBtHsTg(I16zM z9aGGEqcd#G71tEXz(1%k z;bGO1sOcy$bUz^`Z zcN`(rOz~0>kXb}zoF*hqlZ?a=l~M`Kk(n)Yp|Y+H&zqY$ItbS79G-jY`yA0T1SkC@ MvZu7CUJela2QOQjoB#j- literal 0 HcmV?d00001 diff --git a/tests/Bifrost.Web.Tests/Fixtures/desk-feed/cultlib-3a51bbab/answer-revision.msgpack b/tests/Bifrost.Web.Tests/Fixtures/desk-feed/cultlib-3a51bbab/answer-revision.msgpack new file mode 100644 index 0000000000000000000000000000000000000000..aaff18f05180827ad5b5d1739a4a627507255ba0 GIT binary patch literal 461 zcmZ`#F>V_%5cCuL1Qjk^gaXOq@lLAp0|7yh!p&i|T>1#~sLn_&xi`n9K&Uqhy888Yi2E*J)%$md2F}o<3G)Qd+DlQx;N5u7$9qM2W(Xl@%09Ra#W@xvphVTBWG~D+&$- zg%+slAJ_(m^!<*~)`v_FGe3%CmxRNX52MsVq>;ip^5zdN!F7%EjqP(E>1qES8BbTljX*gs7^q3fl&&jQ*VTk+DCY_bBT3i; l^tlbu<-7fCMG=(9pg^z5sVCq=5hc literal 0 HcmV?d00001 diff --git a/tests/Bifrost.Web.Tests/Fixtures/desk-feed/cultlib-3a51bbab/answer-withheld-answerer.msgpack b/tests/Bifrost.Web.Tests/Fixtures/desk-feed/cultlib-3a51bbab/answer-withheld-answerer.msgpack new file mode 100644 index 0000000000000000000000000000000000000000..507479347851701ae2837f81aef0c13410e596f7 GIT binary patch literal 479 zcmZ{gzfQw25XN}~9>D_=45W(lx6Opa$bf_p150$+m&R&h7yDAg>r{xg6vTqWTJaWL zcot$>Ms7HtrQdh=>H9u7d~>447H-fwW%TD5S`=MF1Bq@@f_4vR2eWXsn@T0;nlCD2 zC;hlR`J)3-0~PljI_j4ct}zs}U?+hv+M%X}=}4Fs7w4wagmP}G&C()S5ac#b!bse_ znyDANvIbXg&vH3RD>2Mv8b?VKW}H`;@KkV#Rg^=VBzea3ySr={#c7pf7(>P55D?;w zi)8pLYNG_swRzHpaC>!uIAw}hV+1q>1Lj>a?~*CUs73}I)y5t>)&tEc11*`W!74rW zx*qB^I0XyTvw{ZeT_`9^ppPhwvVik|N7sB*gi#TOw`+?6)$BhYy?qxAsJ2wPtUBr} qel7Pa?Pj%eqv&yYImP~_u`d>XBlgiBg}dT`e}lxgp>O`XFa86FG_BJB literal 0 HcmV?d00001 diff --git a/tests/Bifrost.Web.Tests/Fixtures/desk-feed/cultlib-3a51bbab/card-operator-fork.msgpack b/tests/Bifrost.Web.Tests/Fixtures/desk-feed/cultlib-3a51bbab/card-operator-fork.msgpack new file mode 100644 index 0000000000000000000000000000000000000000..325e6688c37b2c16b049964287414c4cadbe8c1f GIT binary patch literal 577 zcmZ`$OODhq5Cw4qPLKr)5ONgf-`Rk~l4TDz|p=ZgeT<^VldR6{&@8Pv$9ro}Vt&>Lo+Cq)PP$V}g(=CD`< z)x>cKtvjEe{3pGT3du*Kk-*3$YK8}epxtpV6l{-I7NkSIk@{@ElbTO2M!z1Ag%I=8 zF38jQ4uaZ@hB~6mN`O1+=9=_px zeuN39ENwFa`Klm!Sy!a4s}(7sXmghF6sfpA={L-b+TXu)9{lL`CM_KTi)vc literal 0 HcmV?d00001 diff --git a/tests/Bifrost.Web.Tests/Fixtures/desk-feed/cultlib-3a51bbab/card-raised-at-nil.msgpack b/tests/Bifrost.Web.Tests/Fixtures/desk-feed/cultlib-3a51bbab/card-raised-at-nil.msgpack new file mode 100644 index 0000000000000000000000000000000000000000..a5e848efced5c95af8f3bdae948382c6109c69a6 GIT binary patch literal 557 zcmZ`#OODhq6a;YtPLKr)M#xboaX#G}kXW*8iEZ>^KX|i?xSk4I;jxcmj&md+b z7A!~VYh=S&u!o){tLIl$uT-u-PoCd8*5d&0(K>1L?+pydCgoFM>^5a!dHQj2h)XN^ z{PK||tOvjPFro9|YUPyiWB|J*%xH(&@4fU2f2{+aL_9g+hcG>U^7rfBOo}Iv#M6J0 z4inddMgIC=#%SxlonK1+{WH2%C%+z%g%ITMP5TeX1*x|Id!DEbDQAk7%sW>UISKGA~`)X|qll7@mH~rZ}{M z?_WOBg!SN>&mOG{s>Vv~$N*+dm{t~*+dAPS{#^t-iFk6rr%)Y!b^jK<_L3)%MCrrI z5)<2lLH=gaW3;tDPtFAY^$qPNYAzR%O@vD$e5Uk0di@@83}7NP1DReMWO^7-aflXS zYvMSD(f-)KdLn%%B$Dr1Apy??Du!E$pzLnbNm%VJ4G4?873yTO7K%^ryjzUOLWuqA zcq=KEWCf#bn0KuWOl-*gO`Mi!AULL`eDnc#lV^EFC?z!ekR3Ng)@0eI3yw_i@C~O| zhpuJXEBE}|I&j`@ba=+O@lvSO?supmQfKsVy45DgUi>*6t?j|~`?obeo^@ literal 0 HcmV?d00001 diff --git a/tests/Bifrost.Web.Tests/Fixtures/desk-feed/cultlib-3a51bbab/entry-closed-with-ruling-and-a-refusal.msgpack b/tests/Bifrost.Web.Tests/Fixtures/desk-feed/cultlib-3a51bbab/entry-closed-with-ruling-and-a-refusal.msgpack new file mode 100644 index 0000000000000000000000000000000000000000..93e6b2def21e3714ec772affdc0d818f9620fb5b GIT binary patch literal 1853 zcmd6o&2AGh5Xbp=0mKvR0f7*Bwd>t%Ho1UQi3SmqV-a=9@qRr#sM`oOEg z`kB(}K9p8(`J2IrGcArTTwNA_ToyYGYHPQ%BgL2FRl;*-+Zz=ai@(s`h<2^C1&r^Z z&WmcUN()cz*VSBAh47eX3T3@M!^JLmCTAMNomvgtX0!8rD8;KSFeA5Tf7Pve()w3t*+0 zjIx6DCi|L61EM3#=c9F5ih8B8s{`Pe#PpV{ULm`r#|Ea&E88)+;=T}fFk)2!nqfp= z$H#G){XhenkT4`+uokr1QP2*8$9n>}6bNQ}dJO^*a@vgui(3s6Cux(UX|qKV*67AO z5){Jh?Lyz-sw(Zpv9ZinX3PtP$&PhZ$g(%RzLcK^ql#+IWdX?Fi2O2qjdDC;rd5A? zScbbwV4kB$)=q5?TDTPQhfkP6|W{?JP1ki{ZStIGTL=16EL($9{ z-Hfp`;c=L9pks$dijaTh3V#MQCgoFwHD#x%Cegb;RnP z=zh8uw%P%8-G6}KL2kP8pC)KLe#Z+Y`)I;WR@q9!x4mODXS2)xJY{LO_8tt-lUC{1 z8fNztqMlw0W)BUC`y{b@rS9d1^M{6i1)cr@^oNjD=-yMHAI$FAxw-!he|Mq&m-yp$ w@N4|7EQO{>IKj)2kvM8ml7>x0mxVw@#N%#*{lH(ZT6ltgUZ>Hgzo1XQ12i?R1ONa4 literal 0 HcmV?d00001 diff --git a/tests/Bifrost.Web.Tests/Fixtures/desk-feed/cultlib-3a51bbab/entry-open-counted.msgpack b/tests/Bifrost.Web.Tests/Fixtures/desk-feed/cultlib-3a51bbab/entry-open-counted.msgpack new file mode 100644 index 0000000000000000000000000000000000000000..eb8604549b892b27b168bdc355ed646b9243dcd9 GIT binary patch literal 1298 zcmb_cO>fgc5G@Dph+p7CC4|7y+KCe<7mzA(;ebRd4!uO<-Eq9C<4t$hg>ozsXUb0q zX+Bz7gv5t9AVvI(T>4v>&4<)TRP<0EY|rl7@ywg|{O;WF47>0OwUMg$(Sa`VGPjjf z>AeaTRv%Ul*noo;mmBxj!Qa=x4nx?HJK2`v*J{`28Q9i-iN?|wTKmz7l{UxWGs1b% zh^xZl8~b}ZQ)MnZ@Jz0(*9F>4&@&lm6i-H~=MI~XM|~+i9ikbyGm~w%>q%R2%l$&l zS1+C;_Gr<|6^FcXp^>X@7YhL{1))X)dlZ`E*~4pUOl6M#TUDSBrI1)~JjoFXGaaNk zbfyyx(x7O|;%KlZ3o+U%?RF126)}6{*vn<&cc5olytHjYJMP7IjrmsPsDUz8bZwOf z?6;7Gbw3FFfbFnmtIAr8?T!UH0uZj?Z z^n8hLb5$1h&d^w}r5Pw{cBso-7M!!n{41eYL2}gt;-)hL}tbX)3Xdp~_M&I@5a# zJ1fvK%}T~+)O%YMPXtE@$J%2hyZe0+97=^-+59EsY?!Zey36h=F;{At zYcB6&!6UMOn(lzYZbc?e%K*b-_GVtj`rvHo_GRZ_pf_hp@Eqgw>3;8nTxJGa6Y^E7 zDzLtcCnE($5o)m2sAMp?=7SGuA~}V^K|&gst}U3Qv0y*09g~1VGLuMkUpwfg^pQgZ zD_n^!XHAA6v@G<9A_lS4c*ipyk==8B9j*r}4L`JfeT>2b-?sE$1gLI&pef;9v{x(6 zOs3$+XfDlUTvo%)?&x_Bjbx-cQczqjsN(dlUp!&p+Fv)aueyENuzbScuk;N6K+iRZ qGc@J}dL9>-W9i#}Bdxs!|4U_~hJQt6^QM6v{4=>o*zgy^hCcy`W{`RS literal 0 HcmV?d00001 diff --git a/tests/Bifrost.Web.Tests/Fixtures/desk-feed/cultlib-3a51bbab/entry-withheld-open-counted.msgpack b/tests/Bifrost.Web.Tests/Fixtures/desk-feed/cultlib-3a51bbab/entry-withheld-open-counted.msgpack new file mode 100644 index 0000000000000000000000000000000000000000..2d91b27b832b7e8f16793ad3158f1794e4f8476e GIT binary patch literal 1223 zcmb_c&2AGh5H1Jqh$q+s5<;+%cblY1E+AFn!U2g^9D0c+_H5SbuASQ6LOB+x=axqZ zX*OwT5fVS*fE4i-x%62W=SONJDmc^!+hc#8o%!aQeScwjiaESSW2IK#yO1LMGpGw*t#<01GX{xR-)LYnVZ70)MIymkhizb^-oyxEfM%`H z5Eu!pH8v9H3_X!X9IcAr$CARiV&<6tlEE#9_hrTnQ9yNigN78?SJCC%Aal-KIk)Y} z)!MzA@(^fu7fvXT@pX6q)^@22M{>h*(^m>bUni51L1%zFk`LDcC%2sVkf&O5^zv8Q z;q=vt{#z>@C2inR44`nSHV``wxZO#nN{ufll W=>s+!F$?_~R{hlQlQ-uhW`6*#%hbUD literal 0 HcmV?d00001 diff --git a/tests/Bifrost.Web.Tests/Fixtures/desk-feed/record-non-decider.proposed.payload.hex b/tests/Bifrost.Web.Tests/Fixtures/desk-feed/record-non-decider.proposed.payload.hex deleted file mode 100644 index 4053399..0000000 --- a/tests/Bifrost.Web.Tests/Fixtures/desk-feed/record-non-decider.proposed.payload.hex +++ /dev/null @@ -1 +0,0 @@ -86ad736368656d6156657273696f6eb767616d6563756c742e666f726b2e7265636f72642e7630a7666f726b5f6964d930657572656b612d7375627374726174653a7175657374696f6e3a6465736b2d6c697374696e672d617574686f72697479ac6f7074696f6e735f68617368d94037643935666338376435333234323036313166653431356331646566323761333434373631376262363832333566343665336166313330616561333631633438b1636f756e7465645f616e737765725f6964a26e31ae616e7377657265725f636f756e7402a7616e737765727392de0010ad736368656d6156657273696f6eb767616d6563756c742e6465736b5f616e737765722e7630a9616e737765725f6964a26e31a7666f726b5f6964d930657572656b612d7375627374726174653a7175657374696f6e3a6465736b2d6c697374696e672d617574686f72697479a76f7574636f6d65a7436f756e746564a26f66c0a87265747261637473c0a4636f6465c0ac6f7074696f6e735f68617368d94037643935666338376435333234323036313166653431356331646566323761333434373631376262363832333566343665336166313330616561333631633438a663686f696365ab61736b696e672d6d696e64a46e6f7465be5468652061736b6572206c6973747320686572206f776e20666f726b732eab616e7377657265645f6174b4323032362d31312d31315431373a30303a30305aab72656365697665645f6174b4323032362d31312d31315431373a30303a30305aaf636c61696d5f696e5f667574757265c2a8616e737765726572c0a9617574686f72697479a64d656d626572aa726571756573745f6964d92430303030303030302d303030302d343030302d383030302d303030303030303030303031de0010ad736368656d6156657273696f6eb767616d6563756c742e6465736b5f616e737765722e7630a9616e737765725f6964a26e32a7666f726b5f6964d930657572656b612d7375627374726174653a7175657374696f6e3a6465736b2d6c697374696e672d617574686f72697479a76f7574636f6d65a85265766973696f6ea26f66a26e31a87265747261637473c0a4636f6465c0ac6f7074696f6e735f68617368d94037643935666338376435333234323036313166653431356331646566323761333434373631376262363832333566343665336166313330616561333631633438a663686f696365ab61736b696e672d6d696e64a46e6f7465a74167726565642eab616e7377657265645f6174b4323032362d31312d31315431373a30353a30305aab72656365697665645f6174b4323032362d31312d31315431373a30353a30305aaf636c61696d5f696e5f667574757265c2a8616e737765726572c0a9617574686f72697479a64d656d626572aa726571756573745f6964d92430303030303030302d303030302d343030302d383030302d303030303030303030303032 diff --git a/tests/Bifrost.Web.Tests/Fixtures/desk-feed/record-non-decider.proposed.payload.msgpack b/tests/Bifrost.Web.Tests/Fixtures/desk-feed/record-non-decider.proposed.payload.msgpack deleted file mode 100644 index d1844792604e05ecfa6fc789c084223d9f192c9b..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1084 zcmc(eO-chX6vxFAc!Vz8PMOTNT`8{JNO9q2NRv06&`zRBro{_*0FO{gr?q|{2=1hK zi*7uNNn6E*A5axT$mE}7!h8SU%lWk;ITZK^q+)_Uv~dBX?CN?ZWT!5H2ubTbx3V&2 zbnZeap@SV&wv?7wL*ujrrOmGm3aaCDnGwA0;8N#8GJSR>PVBBqbFA|DZcKN=j3hA) zeJ}9b2%!uD6cR)s^J44=K^&pD)ru0&53?WwA7{vSFjNZFkii`*i|4 sBzCZJ)zDhtyq|*`A3~4WhhWH=!ult6)m~cy&@Ul{-$7a&_)AFM3sQ-X#Q*>R diff --git a/tests/Bifrost.Web.Tests/Fixtures/desk-feed/record-whole.payload.hex b/tests/Bifrost.Web.Tests/Fixtures/desk-feed/record-whole.payload.hex index aa5f793..5a76c83 100644 --- a/tests/Bifrost.Web.Tests/Fixtures/desk-feed/record-whole.payload.hex +++ b/tests/Bifrost.Web.Tests/Fixtures/desk-feed/record-whole.payload.hex @@ -1 +1 @@ -85ad736368656d6156657273696f6eb767616d6563756c742e666f726b2e7265636f72642e7630a7666f726b5f6964d930657572656b612d7375627374726174653a7175657374696f6e3a6465736b2d6c697374696e672d617574686f72697479ac6f7074696f6e735f68617368d94037643935666338376435333234323036313166653431356331646566323761333434373631376262363832333566343665336166313330616561333631633438b1636f756e7465645f616e737765725f6964a26e31a7616e737765727392de0010ad736368656d6156657273696f6eb767616d6563756c742e6465736b5f616e737765722e7630a9616e737765725f6964a26e31a7666f726b5f6964d930657572656b612d7375627374726174653a7175657374696f6e3a6465736b2d6c697374696e672d617574686f72697479a76f7574636f6d65a7436f756e746564a26f66c0a87265747261637473c0a4636f6465c0ac6f7074696f6e735f68617368d94037643935666338376435333234323036313166653431356331646566323761333434373631376262363832333566343665336166313330616561333631633438a663686f696365ab61736b696e672d6d696e64a46e6f7465be5468652061736b6572206c6973747320686572206f776e20666f726b732eab616e7377657265645f6174b4323032362d31312d31315431373a30303a30305aab72656365697665645f6174b4323032362d31312d31315431373a30303a30305aaf636c61696d5f696e5f667574757265c2a8616e737765726572d92435663063326231652d386134642d346333622d396537662d316132623363346435653666a9617574686f72697479a64d656d626572aa726571756573745f6964d92430303030303030302d303030302d343030302d383030302d303030303030303030303031de0010ad736368656d6156657273696f6eb767616d6563756c742e6465736b5f616e737765722e7630a9616e737765725f6964a26e32a7666f726b5f6964d930657572656b612d7375627374726174653a7175657374696f6e3a6465736b2d6c697374696e672d617574686f72697479a76f7574636f6d65a85265766973696f6ea26f66a26e31a87265747261637473c0a4636f6465c0ac6f7074696f6e735f68617368d94037643935666338376435333234323036313166653431356331646566323761333434373631376262363832333566343665336166313330616561333631633438a663686f696365ab61736b696e672d6d696e64a46e6f7465a74167726565642eab616e7377657265645f6174b4323032362d31312d31315431373a30353a30305aab72656365697665645f6174b4323032362d31312d31315431373a30353a30305aaf636c61696d5f696e5f667574757265c2a8616e737765726572d92430623964376533612d366332312d346635382d613064342d396538663761366235633464a9617574686f72697479a64d656d626572aa726571756573745f6964d92430303030303030302d303030302d343030302d383030302d303030303030303030303032 +85ad736368656d6156657273696f6eb767616d6563756c742e666f726b2e7265636f72642e7630a7666f726b5f6964d930657572656b612d7375627374726174653a7175657374696f6e3a6465736b2d6c697374696e672d617574686f72697479ac6f7074696f6e735f68617368d94037643935666338376435333234323036313166653431356331646566323761333434373631376262363832333566343665336166313330616561333631633438b1636f756e7465645f616e737765725f6964a26e31a7616e737765727394de0010ad736368656d6156657273696f6eb767616d6563756c742e6465736b5f616e737765722e7630a9616e737765725f6964a26e31a7666f726b5f6964d930657572656b612d7375627374726174653a7175657374696f6e3a6465736b2d6c697374696e672d617574686f72697479a76f7574636f6d65a7436f756e746564a26f66c0a87265747261637473c0a4636f6465c0ac6f7074696f6e735f68617368d94037643935666338376435333234323036313166653431356331646566323761333434373631376262363832333566343665336166313330616561333631633438a663686f696365ab61736b696e672d6d696e64a46e6f7465be5468652061736b6572206c6973747320686572206f776e20666f726b732eab616e7377657265645f6174b4323032362d31312d31315431373a30303a30305aab72656365697665645f6174b4323032362d31312d31315431373a30303a30305aaf636c61696d5f696e5f667574757265c2a8616e737765726572d92435663063326231652d386134642d346333622d396537662d316132623363346435653666a9617574686f72697479a64d656d626572aa726571756573745f6964d92430303030303030302d303030302d343030302d383030302d303030303030303030303031de0010ad736368656d6156657273696f6eb767616d6563756c742e6465736b5f616e737765722e7630a9616e737765725f6964a26e32a7666f726b5f6964d930657572656b612d7375627374726174653a7175657374696f6e3a6465736b2d6c697374696e672d617574686f72697479a76f7574636f6d65a85265766973696f6ea26f66a26e31a87265747261637473c0a4636f6465c0ac6f7074696f6e735f68617368d94037643935666338376435333234323036313166653431356331646566323761333434373631376262363832333566343665336166313330616561333631633438a663686f696365ab61736b696e672d6d696e64a46e6f7465a74167726565642eab616e7377657265645f6174b4323032362d31312d31315431373a30353a30305aab72656365697665645f6174b4323032362d31312d31315431373a30353a30305aaf636c61696d5f696e5f667574757265c2a8616e737765726572d92430623964376533612d366332312d346635382d613064342d396538663761366235633464a9617574686f72697479a64d656d626572aa726571756573745f6964d92430303030303030302d303030302d343030302d383030302d303030303030303030303032de0010ad736368656d6156657273696f6eb767616d6563756c742e6465736b5f616e737765722e7630a9616e737765725f6964a26e33a7666f726b5f6964d930657572656b612d7375627374726174653a7175657374696f6e3a6465736b2d6c697374696e672d617574686f72697479a76f7574636f6d65a752656675736564a26f66c0a87265747261637473c0a4636f6465ad6e6f745f615f64656369646572ac6f7074696f6e735f68617368d94037643935666338376435333234323036313166653431356331646566323761333434373631376262363832333566343665336166313330616561333631633438a663686f696365ab61736b696e672d6d696e64a46e6f7465a74d6520746f6f2eab616e7377657265645f6174b4323032362d31312d31315431373a30363a30305aab72656365697665645f6174b4323032362d31312d31315431373a30363a30305aaf636c61696d5f696e5f667574757265c2a8616e737765726572d92463336131663265342d376236642d346538662d396130622d316332643365346635613662a9617574686f72697479a64d656d626572aa726571756573745f6964d92430303030303030302d303030302d343030302d383030302d303030303030303030303033de0010ad736368656d6156657273696f6eb767616d6563756c742e6465736b5f616e737765722e7630a9616e737765725f6964a26e34a7666f726b5f6964d930657572656b612d7375627374726174653a7175657374696f6e3a6465736b2d6c697374696e672d617574686f72697479a76f7574636f6d65aa52657472616374696f6ea26f66c0a87265747261637473a26e32a4636f6465c0ac6f7074696f6e735f68617368d94037643935666338376435333234323036313166653431356331646566323761333434373631376262363832333566343665336166313330616561333631633438a663686f696365c0a46e6f7465c0ab616e7377657265645f6174b4323032362d31312d31315431373a30373a30305aab72656365697665645f6174b4323032362d31312d31315431373a30373a30305aaf636c61696d5f696e5f667574757265c2a8616e737765726572d92430623964376533612d366332312d346635382d613064342d396538663761366235633464a9617574686f72697479a64d656d626572aa726571756573745f6964d92430303030303030302d303030302d343030302d383030302d303030303030303030303034 diff --git a/tests/Bifrost.Web.Tests/Fixtures/desk-feed/record-whole.payload.msgpack b/tests/Bifrost.Web.Tests/Fixtures/desk-feed/record-whole.payload.msgpack index 1c8b4ed036d57530d09dfe56fb7443d2aa3de56f..78e2ed304caa0aa89e494128c4800d5c7f9938eb 100644 GIT binary patch delta 215 zcmeyy(IPP6EaQ}o=Tn@GqWrW2D~eJ}iV~AciVrMF z&QD2Qo0ne_pBSH#nw*)ES~M}yfAS<|NjBe9g_8XI$s3tv8O&hj8je0OcTwLCTB4@0xbsGZUV8LLwZ#Z#LCS4 sJQNo!$}^g5%N)aZUsRvdk<`tKx7EKml5@j?8+iDK9wUyBX0M+qM8UO$Q delta 12 UcmZn>_{K5eEaRk&=T Convert.FromHexString((string)hex!); + + // {variant: {key: , ..., "as_of": asOf}}: the raw bytes ride as they are. + public static byte[] Variant(string variant, (string Key, byte[] Raw)[] fields, ulong asOf = 1) + { + var buffer = new ArrayBufferWriter(); + var w = new MessagePackWriter(buffer); + w.WriteMapHeader(1); + w.Write(variant); + w.WriteMapHeader(fields.Length + 1); + foreach (var (key, raw) in fields) + { + w.Write(key); + w.WriteRaw(raw); + } + + w.Write("as_of"); + w.Write(asOf); + w.Flush(); + return buffer.WrittenSpan.ToArray(); + } + + public static byte[] Str(string? value) + { + var buffer = new ArrayBufferWriter(); + var w = new MessagePackWriter(buffer); + w.Write(value); + w.Flush(); + return buffer.WrittenSpan.ToArray(); + } + + public static byte[] Forks(byte[] list) => Variant("Forks", [("list", list)]); + + public static byte[] Fork(byte[] entry) => Variant("Fork", [("entry", entry)]); + + public static byte[] Answered(byte[] answer, string? counted = null) => + Variant("Answered", [("answer", answer), ("counted_answer_id", Str(counted))]); + + // A socket that answers every request with these payload bytes, built into a frame from the request's id and operation. + public static FakeHuginnSocket Socket(byte[] payload, string status = "accepted") => + new(FakeHuginnSocket.Build((id, operation) => DeskWire.ResponseFrame(id, operation, status, payload))); + + private static readonly DeskDoorContext Context = new("gamecult-chat", "Member", "5f0c2b1e-8a4d-4c3b-9e7f-1a2b3c4d5e6f", ["5f0c2b1e-8a4d-4c3b-9e7f-1a2b3c4d5e6f"]); + + public static async Task ListAsync(byte[] listBytes, string mind = "gamecult-chat") + { + using var huginn = Socket(Forks(listBytes)); + var outcome = await new UnixSocketDeskDoor().ListAsync(huginn.Path, Context with { Mind = mind }, new DeskListRequest(mind, "open", null, 50), CancellationToken.None); + return Assert.IsType(outcome).List; + } + + public static async Task ReadAsync(byte[] entryBytes) + { + using var huginn = Socket(Fork(entryBytes)); + var outcome = await new UnixSocketDeskDoor().ReadAsync(huginn.Path, Context, "gamecult-chat:question:slot-mark-consent", CancellationToken.None); + return Assert.IsType(outcome).Entry; + } + + public static async Task AnswerAsync(byte[] answerBytes) + { + using var huginn = Socket(Answered(answerBytes)); + var outcome = await new UnixSocketDeskDoor().AnswerAsync(huginn.Path, Context, DeskReplay.AnswerBody(DeskReplay.ChatFork), CancellationToken.None); + return Assert.IsType(outcome).Result.Answer; + } + + // What leaves the door as JSON text, written the way the edge writes it. + public static string Text(T value) => JsonSerializer.SerializeToNode(value, DeskJson.Options)!.ToJsonString(DeskJson.Options); + + public static string Text(JsonNode node) => node.ToJsonString(DeskJson.Options); +} diff --git a/tests/Bifrost.Web.Tests/Support/DeskVectors.cs b/tests/Bifrost.Web.Tests/Support/DeskVectors.cs index 7df0979..91c8f3c 100644 --- a/tests/Bifrost.Web.Tests/Support/DeskVectors.cs +++ b/tests/Bifrost.Web.Tests/Support/DeskVectors.cs @@ -3,12 +3,13 @@ using System.Text.Json.Nodes; namespace Bifrost.Web.Tests.Support; -// CultLib's fork-card vectors, vendored at commit 3a51bbabad244a56ec4521080530d88744001ce4 (#117 on af914253 #115, the final card contract). +// CultLib's fork-card vectors, vendored at commit d3025d3c19674803ad32eb2335461b8cbc22bd28 (#118: append-only on 3a51bbab, +// card DE0012 and record 86 unchanged). public static class DeskVectors { - public const string SourceCommit = "3a51bbabad244a56ec4521080530d88744001ce4"; + public const string SourceCommit = "d3025d3c19674803ad32eb2335461b8cbc22bd28"; - public const string FileSha256 = "13afdcba1f45fd09eb433142c222d435b542cc891e0263df2da0c37ff522d39d"; + public const string FileSha256 = "c2b215a81e6708855b2424f8383f1dff0f3877b7fc9264102ca61d302b00c24c"; public static string Path => System.IO.Path.Combine(AppContext.BaseDirectory, "Fixtures", "fork-card-vectors.json"); diff --git a/tests/Bifrost.Web.Tests/UnixSocketDeskDoorTests.cs b/tests/Bifrost.Web.Tests/UnixSocketDeskDoorTests.cs index 9c8d9e8..3665b5c 100644 --- a/tests/Bifrost.Web.Tests/UnixSocketDeskDoorTests.cs +++ b/tests/Bifrost.Web.Tests/UnixSocketDeskDoorTests.cs @@ -8,7 +8,7 @@ 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 79d954c). +// The production door against a real unix socket and Huginn's golden frames (fixtures at Huginn b299d6f7, vectors at CultLib d3025d3c). public sealed class UnixSocketDeskDoorTests { private const string Fork = "eureka-substrate:question:desk-listing-authority"; @@ -242,134 +242,168 @@ public sealed class UnixSocketDeskDoorTests // ---- (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. + // What each piece of the fixtures directory is (its two READMEs): + // - record-whole is HUGINN's own encoder output at b299d6f7: gamecult.fork.record.v0 with all four answer variants + // by three accounts, notes and ids whole. It has 5 keys and NO answerer_count: what the door sends today. + // - cultlib-3a51bbab/*.msgpack are CULTLIB's bytes (twelve vectors pinned to 3a51bbab, each a vector's + // messagePackHex decoded), vendored unedited. They are NOT Huginn output; Huginn's types do not carry those + // shapes yet. Bifrost reads them as the contract (vectors file d3025d3c, append-only on 3a51bbab) spells them. 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() + private static byte[] CultLib(string name) => + File.ReadAllBytes(Path.Combine(DeskFeedFixturePinTests.Directory, "cultlib-3a51bbab", name + ".msgpack")); + + private static JsonObject CultLibJson(string name) => JsonNode.Parse(MessagePackSerializer.ConvertToJson(CultLib(name)))!.AsObject(); + + // file, vector section, vector name (the vector whose messagePackHex the file holds) + public static TheoryData CultLibFiles() => new() { - var whole = Fragment("record-whole"); - var record = new JsonObject(); - foreach (var (key, value) in whole.ToList()) + { "card-operator-fork", "card/valid", "operator_fork" }, + { "card-raised-at-nil", "card/valid", "raised_at_nil" }, + { "card-withheld-deciders", "card/valid", "withheld_deciders" }, + { "answer-counted", "deskAnswer/valid", "counted" }, + { "answer-revision", "deskAnswer/valid", "revision" }, + { "answer-retraction", "deskAnswer/valid", "retraction" }, + { "answer-withheld-answerer", "deskAnswer/valid", "withheld_answerer" }, + { "answer-refused-stale", "deskAnswer/valid", "refused_stale" }, + { "entry-open-counted", "transport/entry/valid", "open_counted" }, + { "entry-withheld-open-counted", "transport/entry/valid", "withheld_open_counted" }, + { "entry-closed-with-ruling-and-a-refusal", "transport/entry/valid", "closed_with_ruling_and_a_refusal" }, + { "entry-withheld-closed-with-ruling-and-a-refusal", "transport/entry/valid", "withheld_closed_with_ruling_and_a_refusal" }, + }; + + [Theory] + [MemberData(nameof(CultLibFiles))] + public void Each_CultLib_file_is_its_vectors_wire_bytes_in_the_vendored_vectors_file(string file, string section, string name) + { + var vector = DeskVectors.Rows(section.Split('/')).Single(r => (string)r["name"]! == name); + + Assert.Equal((string)vector["messagePackHex"]!, Convert.ToHexString(CultLib(file)), ignoreCase: true); + Assert.True(DeskVectors.SameShape(vector["message"], CultLibJson(file)), file); + } + + [Fact] + public void The_CultLib_files_are_the_shapes_their_README_names() + { + // Card: 18 keys (DE 00 12), raised_at a string / nil with the key kept, deciders whole or withheld with the count. + Assert.Equal([0xde, 0x00, 0x12], CultLib("card-operator-fork")[..3]); + Assert.Equal(1, (int)CultLibJson("card-operator-fork")["decider_count"]!); + Assert.NotEmpty(CultLibJson("card-operator-fork")["deciders"]!.AsArray()); + Assert.Equal(JsonValueKind.String, CultLibJson("card-operator-fork")["raised_at"]!.GetValueKind()); + Assert.True(CultLibJson("card-raised-at-nil").ContainsKey("raised_at")); + Assert.Null(CultLibJson("card-raised-at-nil")["raised_at"]); + Assert.Empty(CultLibJson("card-withheld-deciders")["deciders"]!.AsArray()); + Assert.Equal(2, (int)CultLibJson("card-withheld-deciders")["decider_count"]!); + + // Answers: 16 keys (DE 00 10), answerer a string except the withheld one. + foreach (var answer in new[] { "answer-counted", "answer-revision", "answer-retraction", "answer-refused-stale", "answer-withheld-answerer" }) { - whole.Remove(key); - record[key] = value; - if (key == "counted_answer_id") - { - record["answerer_count"] = 2; - } + Assert.Equal([0xde, 0x00, 0x10], CultLib(answer)[..3]); + Assert.Equal(answer == "answer-withheld-answerer", CultLibJson(answer)["answerer"] is null); } - return record; + // Entries: header 83, record header 86 with answerer_count the fifth key; the decider view names every answerer, + // its non-decider twin none, and the count is the same in both. + foreach (var (decider, withheld) in new[] { ("entry-open-counted", "entry-withheld-open-counted"), ("entry-closed-with-ruling-and-a-refusal", "entry-withheld-closed-with-ruling-and-a-refusal") }) + { + Assert.Equal(0x83, CultLib(decider)[0]); + var (whole, hidden) = (CultLibJson(decider), CultLibJson(withheld)); + Assert.Equal("answerer_count", whole["record"]!.AsObject().ElementAt(4).Key); + Assert.Equal(6, whole["record"]!.AsObject().Count); + Assert.NotEmpty(whole["card"]!["deciders"]!.AsArray()); + Assert.All(whole["record"]!["answers"]!.AsArray(), a => Assert.NotNull(a!["answerer"])); + Assert.Empty(hidden["card"]!["deciders"]!.AsArray()); + Assert.All(hidden["record"]!["answers"]!.AsArray(), a => Assert.Null(a!["answerer"])); + Assert.Equal((int)whole["record"]!["answerer_count"]!, (int)hidden["record"]!["answerer_count"]!); + Assert.Equal((int)whole["card"]!["decider_count"]!, (int)hidden["card"]!["decider_count"]!); + } + + Assert.Equal(1, (int)CultLibJson("entry-open-counted")["record"]!["answerer_count"]!); + Assert.Equal(2, (int)CultLibJson("entry-closed-with-ruling-and-a-refusal")["record"]!["answerer_count"]!); } - // 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) + [Fact] + public void Every_account_id_in_record_whole_is_a_lowercase_D_format_uuid_and_the_record_is_what_the_README_says() { - 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); + var whole = Fragment("record-whole"); + // Huginn's own record: 5 keys, no answerer_count (the README says so; the contract wants a sixth). + Assert.Equal(["schemaVersion", "fork_id", "options_hash", "counted_answer_id", "answers"], whole.Select(p => p.Key)); + Assert.Equal(["Counted", "Revision", "Refused", "Retraction"], whole["answers"]!.AsArray().Select(a => (string)a!["outcome"]!).Distinct()); + + 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}$"); + var accounts = whole["answers"]!.AsArray().Select(a => (string)a!["answerer"]!).ToList(); + Assert.All(accounts, id => Assert.Matches(grammar, id)); + Assert.Equal(3, accounts.Distinct().Count()); } - private static string EntryOf(string card, JsonObject record) => - $$$"""{"schemaVersion":"gamecult.fork.entry.v0","card":{{{card}}},"record":{{{record.ToJsonString(DeskJson.Options)}}}}"""; + // A decider's entry and its non-decider twin, each served through the real door as a list page: the card (18 keys, + // raised_at, decider_count) and the record (answerer_count) leave exactly as CultLib wrote them. + [Theory] + [InlineData("entry-open-counted")] + [InlineData("entry-withheld-open-counted")] + [InlineData("entry-closed-with-ruling-and-a-refusal")] + [InlineData("entry-withheld-closed-with-ruling-and-a-refusal")] + public async Task A_CultLib_entry_in_either_view_comes_through_the_door_unchanged(string file) + { + var entry = CultLibJson(file); + using var huginn = new FakeHuginnSocket(FakeHuginnSocket.Answer((_, _) => ListOf(entry.ToJsonString(DeskJson.Options)))); + + var listed = Assert.IsType(await List(new UnixSocketDeskDoor(), huginn.Path)); + + var got = Assert.Single(listed.List.Forks); + Assert.Equal(DeskServe.Text(entry), DeskServe.Text(got)); + var withheld = file.Contains("withheld", StringComparison.Ordinal); + Assert.Equal(withheld, got.Card.GetProperty("deciders").GetArrayLength() == 0); + Assert.All(got.Record.Answers, a => Assert.Equal(withheld, a.Answerer is null)); + } private static string ListOf(string entry, string mind = "eureka") => $$$"""{"Forks":{"list":{"schemaVersion":"gamecult.fork.list.v0","mind":"{{{mind}}}","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() + public async Task A_decider_entry_keeps_its_ids_and_notes_and_a_non_decider_entry_has_nil_answerers_the_count_and_no_notes_through_the_edge() { - 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(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 nonDecider = Fragment("record-non-decider.proposed"); - using var huginn = new FakeHuginnSocket(FakeHuginnSocket.Answer((_, _) => ListOf(EntryOf(ViewCard("card-viewers-non-decider.synthetic"), nonDecider), "gamecult-chat"))); + var withheld = CultLibJson("entry-withheld-closed-with-ruling-and-a-refusal"); + using var huginn = new FakeHuginnSocket(FakeHuginnSocket.Answer((_, _) => ListOf(withheld.ToJsonString(DeskJson.Options), "gamecult-chat"))); 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 => + var shown = JsonNode.Parse(reply.Text)!["forks"]![0]!; + Assert.Equal(2, (int)shown["record"]!["answerer_count"]!); + Assert.All(shown["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); + Assert.Empty(shown["card"]!["deciders"]!.AsArray()); + Assert.Equal((int)withheld["card"]!["decider_count"]!, (int)shown["card"]!["decider_count"]!); - // 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), "gamecult-chat"))); + // The decider's view keeps every id and every note. + var decider = CultLibJson("entry-closed-with-ruling-and-a-refusal"); + using var huginn2 = new FakeHuginnSocket(FakeHuginnSocket.Answer((_, _) => ListOf(decider.ToJsonString(DeskJson.Options), "gamecult-chat"))); 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)); + Assert.Equal(DeskServe.Text(decider), DeskServe.Text(JsonNode.Parse(own.Text)!["forks"]![0]!)); } - // 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. + // Huginn's record-whole at b299d6f7 still has no answerer_count, which the contract requires (the README says "what + // the door sends today"; the real types follow in cut-desk-feed-listing). 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 record 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")); + var card = CultLibJson("entry-open-counted")["card"]!; + var entry = $$$"""{"schemaVersion":"gamecult.fork.entry.v0","card":{{{card.ToJsonString(DeskJson.Options)}}},"record":{{{Fragment("record-whole").ToJsonString(DeskJson.Options)}}}}"""; using var huginn = new FakeHuginnSocket(FakeHuginnSocket.Answer((_, _) => ListOf(entry))); var failure = await Assert.ThrowsAsync(() => List(new UnixSocketDeskDoor(), huginn.Path));