The leaf owns the document and refusal types, so it owns their
serialisation. Huginn's admission batch cannot derive Serialize while
PipelineDocument does not, and mirrors PipelineRefusal through a
serde(remote) definition kept in step by hand; neither is the wire's
business.
PipelineDocument is adjacently tagged on the kind name: a document on a
wire is { kind, value }, and kind is exactly PipelineKind::name(), so a
reader dispatches on the kind segment it already knows from the key and
needs no second registry mapping variant spellings to kinds. Adjacent
rather than internal because a value is a named map of its own.
PipelineRefusal stays externally tagged, serde's default, which is what
keeps every variant's field and value on the wire under their own names.
No kind, field, type id or epoch moves, and the published per-kind
schemas are untouched: the envelope is the wire's shape, not a document's.
every_document_and_refusal_serialises_and_reads_back round-trips every
sample document and every refusal variant through serde_json and
rmp_serde, and holds each derived schema's variant list to the thirteen
kinds by name and to the four refusals. Mutations D1 (the tag rename
removed) and D2 (a refusal's field skipped) are both killed by it.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
66 lines
3.4 KiB
PowerShell
66 lines
3.4 KiB
PowerShell
# Eureka Cut 8 mutation suite, the Epiphany half: the epoch constant and the
|
|
# live registrar. Entries only; the harness is tools/eureka-mutations.ps1.
|
|
#
|
|
# powershell -File tools/eureka-mutations.ps1 `
|
|
# -Entries tools/eureka-cut8-epiphany-mutations.psd1 `
|
|
# -Target epiphany-pipeline/src/lib.rs `
|
|
# -Test 'cargo test -p epiphany-pipeline --lib'
|
|
#
|
|
# E1-E3 are killed by `every_kind_is_at_the_epochs_version`: it reads the
|
|
# version segment off the constant and holds every type id to it, so a wrong
|
|
# epoch dies whether it is `.v2` or `.v1x`; and it counts what the live
|
|
# registrar registers against `PipelineKind::ALL`, so one type fewer and one
|
|
# foreign type more both die on the count.
|
|
#
|
|
# D1 and D2 are the derives the wire carries a batch through, and both are
|
|
# killed by `every_document_and_refusal_serialises_and_reads_back`: the tag a
|
|
# reader dispatches on is asserted against `PipelineKind::name()` for every
|
|
# kind, and every refusal variant is round-tripped whole, so a field that
|
|
# leaves the wire comes back empty and is not the refusal that went out.
|
|
@{
|
|
Mutations = @(
|
|
@{
|
|
Id = 'E1'
|
|
Rule = 'The epoch names the version every kind is published at; a bumped epoch fails until the kinds move with it.'
|
|
Test = 'tests::every_kind_is_at_the_epochs_version'
|
|
Old = 'pub const PIPELINE_SCHEMA_EPOCH: &str = "epiphany.pipeline.epoch.v1";'
|
|
New = 'pub const PIPELINE_SCHEMA_EPOCH: &str = "epiphany.pipeline.epoch.v2";'
|
|
},
|
|
@{
|
|
Id = 'E2'
|
|
Rule = 'The live registrar registers every kind: one fewer is refused on the count.'
|
|
Test = 'tests::every_kind_is_at_the_epochs_version'
|
|
Old = ' $(cache.register_entry_type::<$document>()?;)*'
|
|
New = ' let mut first = true; $(if !first { cache.register_entry_type::<$document>()?; } first = false;)*'
|
|
},
|
|
@{
|
|
Id = 'E3'
|
|
Rule = 'The live registrar registers nothing but the kinds: the foreign stand-in registered again under cfg(test) is refused on the count.'
|
|
Test = 'tests::every_kind_is_at_the_epochs_version'
|
|
Old = @'
|
|
$(cache.register_entry_type::<$document>()?;)*
|
|
Ok(())
|
|
'@
|
|
New = @'
|
|
$(cache.register_entry_type::<$document>()?;)*
|
|
#[cfg(test)]
|
|
cache.register_entry_type::<ForeignDocument>()?;
|
|
Ok(())
|
|
'@
|
|
},
|
|
@{
|
|
Id = 'D1'
|
|
Rule = 'The document tag is the kind name: a wire reader dispatches on the same string the key segment carries, so the variant spelling is renamed to it and not left as Rust case.'
|
|
Test = 'tests::every_document_and_refusal_serialises_and_reads_back'
|
|
Old = ' #[serde(tag = "kind", content = "value", rename_all = "snake_case")]'
|
|
New = ' #[serde(tag = "kind", content = "value")]'
|
|
},
|
|
@{
|
|
Id = 'D2'
|
|
Rule = 'A refusal carries its named parts over the wire: the field it refused is on the wire, not dropped and defaulted back on the reader.'
|
|
Test = 'tests::every_document_and_refusal_serialises_and_reads_back'
|
|
Old = ' FieldBound { field: String, limit: u32, actual: u32 },'
|
|
New = ' FieldBound { #[serde(skip)] field: String, limit: u32, actual: u32 },'
|
|
}
|
|
)
|
|
}
|