Desk feed door: re-pin CultLib vectors to d3025d3c (null answerer pinned on all four variants) (#61)
This commit is contained in:
parent
36dd8ce3ca
commit
f1d5c4039b
18 changed files with 30 additions and 23 deletions
|
|
@ -5,7 +5,7 @@
|
|||
//!
|
||||
//! No fixture written here carries a card: Huginn's types do not carry `raised_at`, `decider_count`,
|
||||
//! `answerer_count` or a nullable `answerer` yet. Those shapes are CultLib's own bytes, vendored at
|
||||
//! one commit in `fixtures/desk-feed/cultlib-3a51bbab/` and checked below.
|
||||
//! one commit in `fixtures/desk-feed/cultlib-d3025d3c/` and checked below.
|
||||
//!
|
||||
//! `cargo test -p huginn-mind --test desk_feed_fixtures` compares every file with what the
|
||||
//! encoders produce now. `HUGINN_WRITE_DESK_FIXTURES=1` rewrites them instead.
|
||||
|
|
@ -255,8 +255,8 @@ fn every_account_id_in_the_fixtures_is_a_lowercase_d_format_uuid() {
|
|||
|
||||
// ---- CultLib's bytes: the reader-count shapes, pinned at one commit. ----
|
||||
|
||||
/// The CultLib commit the vendored vectors come from (#117 on #115). Re-pin: see the README beside them.
|
||||
const CULTLIB_SHA: &str = "3a51bbabad244a56ec4521080530d88744001ce4";
|
||||
/// The CultLib commit the vendored vectors come from (#118 on #117 on #115). Re-pin: see the README beside them.
|
||||
const CULTLIB_SHA: &str = "d3025d3c19674803ad32eb2335461b8cbc22bd28";
|
||||
|
||||
/// Each vendored vector and the SHA-256 of its bytes.
|
||||
const VENDORED: &[(&str, &str)] = &[
|
||||
|
|
@ -267,6 +267,8 @@ const VENDORED: &[(&str, &str)] = &[
|
|||
("answer-revision", "19d7289395ae68cbaf6de1c0a1ef6c843211b2caf9462e1d2268cd0883386315"),
|
||||
("answer-retraction", "89156f41ec3ea54f5d47bd3318913ff013785f4727916875be97785935cb7735"),
|
||||
("answer-withheld-answerer", "b66b4f921cdd374be04af3de34c59e254a5e542027ae8c57f196a3ea3406e427"),
|
||||
("answer-withheld-answerer-revision", "93f7c875f963a7cfeab2a5980b6d5ce81e6753fc9f3f8bf0d7353f3f388144b7"),
|
||||
("answer-withheld-answerer-retraction", "7d0cc555bf9b6f7c345b0da7c504bcd1ed7b46040ff51d1e57c84b2f56655213"),
|
||||
("answer-refused-stale", "3183bc9c483f4a625332cda11ef22a9c8560868a7728b77daa63a1960a3cd3d6"),
|
||||
("entry-open-counted", "b51f499e8dd0465cf5df9d68d8fccbe94dd1339fd3157969693dd0d4ecb2549b"),
|
||||
("entry-withheld-open-counted", "62ccad7a9f41262d6e35d0247315d0bb75d1313b3c9dabe8a99d1aa1b844607f"),
|
||||
|
|
@ -275,7 +277,7 @@ const VENDORED: &[(&str, &str)] = &[
|
|||
];
|
||||
|
||||
fn vendored(name: &str) -> Vec<u8> {
|
||||
let path = PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("tests/fixtures/desk-feed/cultlib-3a51bbab").join(format!("{name}.msgpack"));
|
||||
let path = PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("tests/fixtures/desk-feed/cultlib-d3025d3c").join(format!("{name}.msgpack"));
|
||||
std::fs::read(&path).unwrap_or_else(|error| panic!("{}: {error}", path.display()))
|
||||
}
|
||||
|
||||
|
|
@ -379,7 +381,7 @@ const RECORD_KEYS: [&str; 6] = ["schemaVersion", "fork_id", "options_hash", "cou
|
|||
#[test]
|
||||
fn the_vendored_cultlib_vectors_are_the_pinned_bytes() {
|
||||
assert_eq!(CULTLIB_SHA.len(), 40);
|
||||
let dir = PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("tests/fixtures/desk-feed/cultlib-3a51bbab");
|
||||
let dir = PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("tests/fixtures/desk-feed/cultlib-d3025d3c");
|
||||
let docs = PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("../../docs/desk-feed-door.md");
|
||||
for path in [dir.join("README.md"), docs] {
|
||||
let text = std::fs::read_to_string(&path).unwrap_or_else(|error| panic!("{}: {error}", path.display()));
|
||||
|
|
@ -420,8 +422,8 @@ fn the_cards_are_eighteen_keys_with_raised_at_and_decider_count() {
|
|||
}
|
||||
|
||||
/// `answerer` is a string or nil on every answer; `Value::Nil` only when `named` is false. The bytes
|
||||
/// null it on `Counted` and `Refused` only; nullable on all four variants is the ruling
|
||||
/// `desk-reader-counts-shape`, and CultLib has no vector with a `Revision` or `Retraction` nulled.
|
||||
/// null it on all four variants (`Counted`, `Revision`, `Retraction`, `Refused`), by ruling
|
||||
/// `desk-reader-counts-shape` and now by vector.
|
||||
fn check_answer(answer: &Value, named: bool) {
|
||||
assert_eq!(answer.keys().len(), 16);
|
||||
assert_eq!(answer.keys()[13], "answerer");
|
||||
|
|
@ -434,12 +436,12 @@ fn check_answer(answer: &Value, named: bool) {
|
|||
|
||||
#[test]
|
||||
fn the_answers_keep_sixteen_keys_and_answerer_is_a_string_or_nil() {
|
||||
for (name, named) in [("answer-counted", true), ("answer-revision", true), ("answer-retraction", true), ("answer-refused-stale", true), ("answer-withheld-answerer", false)] {
|
||||
for (name, named) in [("answer-counted", true), ("answer-revision", true), ("answer-retraction", true), ("answer-refused-stale", true), ("answer-withheld-answerer", false), ("answer-withheld-answerer-revision", false), ("answer-withheld-answerer-retraction", false)] {
|
||||
let bytes = vendored(name);
|
||||
assert_eq!(bytes[..3], [0xde, 0x00, 0x10], "{name}: header");
|
||||
check_answer(&decode(&bytes), named);
|
||||
}
|
||||
for (name, outcome) in [("answer-counted", "Counted"), ("answer-revision", "Revision"), ("answer-retraction", "Retraction"), ("answer-refused-stale", "Refused")] {
|
||||
for (name, outcome) in [("answer-counted", "Counted"), ("answer-revision", "Revision"), ("answer-retraction", "Retraction"), ("answer-refused-stale", "Refused"), ("answer-withheld-answerer-revision", "Revision"), ("answer-withheld-answerer-retraction", "Retraction")] {
|
||||
assert_eq!(decode(&vendored(name)).get("outcome").str(), outcome);
|
||||
}
|
||||
}
|
||||
|
|
@ -517,7 +519,9 @@ fn huginn_types_do_not_yet_carry_the_pinned_shapes() {
|
|||
}
|
||||
assert!(refused::<ForkCard>(&vendored("card-operator-fork")).contains("raised_at"));
|
||||
assert!(refused::<ForkCard>(&vendored("card-withheld-deciders")).contains("raised_at"));
|
||||
assert!(refused::<ForkDeskAnswer>(&vendored("answer-withheld-answerer")).contains("string"));
|
||||
for name in ["answer-withheld-answerer", "answer-withheld-answerer-revision", "answer-withheld-answerer-retraction"] {
|
||||
assert!(refused::<ForkDeskAnswer>(&vendored(name)).contains("string"), "{name}");
|
||||
}
|
||||
// The record is the entry's last key: its bytes run from the `86` after the key to the end.
|
||||
let entry = vendored("entry-open-counted");
|
||||
let key = [&[0xa6u8][..], b"record", &[0x86]].concat();
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ lands (see `docs/desk-feed-door.md`).
|
|||
| `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`) |
|
||||
|
||||
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
|
||||
CultLib's own bytes, vendored unedited in `cultlib-d3025d3c/` (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.
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
# 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
|
||||
Source: `GameCult/CultLib` at commit `d3025d3c19674803ad32eb2335461b8cbc22bd28` (#118, on
|
||||
`3a51bbab` #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
|
||||
|
|
@ -13,9 +13,11 @@ from Huginn's encoders: Huginn's own types do not carry these shapes yet (see
|
|||
| `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-revision` | `deskAnswer.valid` `revision` | a `Revision`, `answerer` a string |
|
||||
| `answer-retraction` | `deskAnswer.valid` `retraction` | a `Retraction`, `answerer` a string |
|
||||
| `answer-withheld-answerer` | `deskAnswer.valid` `withheld_answerer` | `answerer` nil |
|
||||
| `answer-withheld-answerer-revision` | `deskAnswer.valid` `withheld_answerer_revision` | a `Revision`, `answerer` nil |
|
||||
| `answer-withheld-answerer-retraction` | `deskAnswer.valid` `withheld_answerer_retraction` | a `Retraction`, `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 |
|
||||
Binary file not shown.
Binary file not shown.
|
|
@ -20,7 +20,7 @@ This page is the wire contract for the consumer, Bifrost's `UnixSocketDeskDoor`
|
|||
`docs/desk-feed-design.md`). The golden bytes are in `crates/huginn-mind/tests/fixtures/desk-feed/`.
|
||||
Huginn's own encoders write them (`crates/huginn-mind/tests/desk_feed_fixtures.rs`), so a decoder
|
||||
that reads them reads the door. The reader-count shapes are CultLib's bytes, vendored in
|
||||
`cultlib-3a51bbab/` (below). The document shapes inside the payload (`gamecult.fork.list.v0`,
|
||||
`cultlib-d3025d3c/` (below). The document shapes inside the payload (`gamecult.fork.list.v0`,
|
||||
`gamecult.fork.entry.v0`, `gamecult.fork.card.v0`, `gamecult.fork.record.v0`,
|
||||
`gamecult.desk_answer.v0`, `gamecult.fork.refusal.v0`) are CultLib's
|
||||
(`contracts/cultnet/governance/fork-card.md`) and are not restated here.
|
||||
|
|
@ -120,11 +120,12 @@ byte; both values are in the account-id format above. Any other reader is a non-
|
|||
Bifrost, withholds account ids from a non-decider and returns a count instead. Bifrost cannot do
|
||||
it, because the card is opaque to it. A decider sees the ids. The superseding ruling is in force:
|
||||
`eureka-substrate:ruling:desk-read-visibility-withheld-ids`.
|
||||
- **The shape**, pinned to CultLib commit `3a51bbabad244a56ec4521080530d88744001ce4` (#117 "Fork card:
|
||||
decider_count, answerer_count, nullable answerer (reader views)", on `af914253` #115 `raised_at`;
|
||||
- **The shape**, pinned to CultLib commit `d3025d3c19674803ad32eb2335461b8cbc22bd28` (#118 "null-answerer vectors for
|
||||
Revision and Retraction", additive over `3a51bbab` #117 "Fork card: decider_count, answerer_count,
|
||||
nullable answerer (reader views)", on `af914253` #115 `raised_at`;
|
||||
ruling `eureka-substrate:ruling:desk-reader-counts-shape`). The bytes are CultLib's own vectors
|
||||
(`contracts/cultnet/governance/fork-card-vectors.json`, `messagePackHex`), vendored unedited in
|
||||
`crates/huginn-mind/tests/fixtures/desk-feed/cultlib-3a51bbab/` (its README lists each file and
|
||||
`crates/huginn-mind/tests/fixtures/desk-feed/cultlib-d3025d3c/` (its README lists each file and
|
||||
its vector name). Read off those bytes:
|
||||
- **Card:** 18 keys, header `DE 00 12` (map16): `schemaVersion` plus 17 fields, in this order:
|
||||
`fork_id, title, context, options, recommendation, depends, leans, flag, raised_in, raised_at,
|
||||
|
|
@ -139,10 +140,10 @@ byte; both values are in the account-id format above. Any other reader is a non-
|
|||
between 1 and the number of answers (0 with no answers).
|
||||
- **Answer:** `gamecult.desk_answer.v0` keeps its 16 keys (header `DE 00 10`); `answerer` is a
|
||||
string or nil, nil only in a non-decider's view, with the key kept. The bytes pin a nil `answerer`
|
||||
on two variants, `Counted` (`answer-withheld-answerer`) and `Refused` (the withheld entries). That
|
||||
it is nullable on all four variants (`Counted`, `Revision`, `Retraction`, `Refused`) is the ruling
|
||||
`eureka-substrate:ruling:desk-reader-counts-shape`, not a vector: CultLib's `revision` and
|
||||
`retraction` vectors carry a string `answerer` and no CultLib vector has either nulled. Stored
|
||||
on all four variants, `Counted` (`answer-withheld-answerer`), `Revision`
|
||||
(`answer-withheld-answerer-revision`), `Retraction` (`answer-withheld-answerer-retraction`) and
|
||||
`Refused` (the withheld entries), beside each variant's string-`answerer` vector; ruling
|
||||
`eureka-substrate:ruling:desk-reader-counts-shape` is the reason, no longer the only evidence. Stored
|
||||
answers always carry it.
|
||||
- **Entry:** header `83` (`schemaVersion, card, record`). The view is read off `deciders`: a
|
||||
non-empty `deciders` names every answerer, an empty one names none.
|
||||
|
|
|
|||
Loading…
Reference in a new issue