S3: Mind::path_for bypassed the grammar door and the daemon's own tests constructed stores through it directly. It is now private; a test-only Mind::store_path_for validates through require_grammatical_slug first, gated behind cfg(test) here and a test-support feature dev-dependents opt into (huginn-daemon's Cargo.toml). The four daemon test call sites and one huginn-mind test call site now go through the door. S2: N1's door, require_grammatical_slug, had no mutation entry for two of its three callers (open_with and require_instance survived deleting it; open already had N1's own escape test). Added a test per caller and a mutation entry for each of the three deletions (N1open, N1openwith, N1requireinstance) in tools/eureka-cut10-mutations.psd1. S4: a Unicode hyphen (U+2010) folded to ASCII '-' before the grammar check survived. Added a fixture and mutation entry (S4fold) pinning that no such fold runs before Slug::validate_slug. S1: the size-gate fixtures varied operation and runtime id together (4/16, 4/16, 10/19), so a formula tracking one and dropping the other still passed. Added a fixture varying them independently (10/16 and 4/19) and two mutation entries (N4c, N4d) for the two formulas that each drop one term. Verified: cargo test -p huginn-mind --lib (65/65), cargo test -p huginn-daemon --lib (20/20, one more than before: the new independent-axis gate test). Mutation suites through the Eureka harness: Cut 8 67/67 killed, Cut 9 38/38 killed, Cut 10 77/77 killed (71 before this batch, +6: N1open, N1openwith, N1requireinstance, S4fold, N4c, N4d). M0 green in every suite. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
1129 lines
56 KiB
PowerShell
1129 lines
56 KiB
PowerShell
# Cut 10 mutations, D1-D22: the CultNet surface's rules. Each rule has a
|
|
# revert, `Dn`, which removes the rule, and a loosening, `DnL`, which weakens
|
|
# it rather than removing it, because a plain revert is the easy target. Every
|
|
# entry names the test that must fail while it is applied. Run through the
|
|
# Eureka skill's harness from this repo:
|
|
#
|
|
# $env:CARGO_TARGET_DIR = 'C:\Users\Meta\.cargo-target-codex'
|
|
# powershell -File C:\Users\Meta\.claude\skills\eureka\tools\eureka-mutations.ps1 -Repo F:\Projects\Huginn `
|
|
# -Entries tools/eureka-cut10-mutations.psd1 `
|
|
# -Target crates/huginn-mind/src/mind.rs,crates/huginn-mind/src/query.rs,crates/huginn-mind/src/wire.rs,crates/huginn-daemon/src/daemon.rs,crates/huginn-daemon/src/envelope.rs,crates/huginn-daemon/src/serve.rs,schemas/cultnet/huginn.mind_request.v1.schema.json,schemas/cultnet/huginn.mind_response.v1.schema.json `
|
|
# -Test 'cargo test -p huginn-daemon --lib'
|
|
#
|
|
# Entries whose test lives in `huginn-mind` carry their own `Command`. `D1` and
|
|
# `D1D` are one mutant run against two suites, which is the point of the rule:
|
|
# `Mind::require_instance` is the one instance check, and admission and the
|
|
# daemon's reads are its two callers. The same edit is `H1` in
|
|
# `eureka-cut8-mutations.psd1`.
|
|
#
|
|
# `M0` is the harness's own no-op control and is not listed here.
|
|
#
|
|
# Two rules have no loosening and say so rather than carrying a weak entry:
|
|
#
|
|
# - `D9`, the connection id the hub serves. It is one `u32` handed to
|
|
# `CultNetRudpServerHubOptions::new`; a hub serves that id or another one,
|
|
# and there is no shape of "serves more ids" to weaken it into.
|
|
# - `D12`'s order, weakened as far as it goes by `D12L`: a hub bound before the
|
|
# mind is opened and then dropped when the mind refuses. Any weaker form is
|
|
# the correct order again.
|
|
#
|
|
# `D17`-`D19` pin three of the dispatch's four read arms and `D23` the fourth.
|
|
# The fourth was once recorded here as unpinnable, on the grounds that
|
|
# `Mind::open_items` raises no refusal of its own; the refusal it carries comes
|
|
# from the reader beneath it over a store whose receipt is gone, and such a
|
|
# store is reachable from this crate's surface, so the entry exists.
|
|
@{
|
|
Mutations = @(
|
|
@{
|
|
Id = 'D1'
|
|
Rule = 'Ruling 14: the mind owns the instance check, and it is a comparison.'
|
|
Test = 'mind::tests::require_instance_is_the_one_check_admission_and_the_daemon_share'
|
|
Command = 'cargo test -p huginn-mind --lib'
|
|
File = 'crates/huginn-mind/src/mind.rs'
|
|
Old = @'
|
|
if declared != self.instance() {
|
|
return Err(MindRefusal::ForeignInstance {
|
|
declared: declared.0.clone(),
|
|
mind: self.instance().0.clone(),
|
|
});
|
|
}
|
|
Ok(())
|
|
'@
|
|
New = @'
|
|
let _ = declared;
|
|
Ok(())
|
|
'@
|
|
}
|
|
@{
|
|
Id = 'D1L'
|
|
Rule = 'The instance check compares the names, not their lengths.'
|
|
Test = 'mind::tests::require_instance_is_the_one_check_admission_and_the_daemon_share'
|
|
Command = 'cargo test -p huginn-mind --lib'
|
|
File = 'crates/huginn-mind/src/mind.rs'
|
|
Old = ' if declared != self.instance() {'
|
|
New = ' if declared.0.len() != self.instance().0.len() {'
|
|
}
|
|
@{
|
|
Id = 'D1L2'
|
|
Rule = 'It compares the names whole, not their first byte.'
|
|
Test = 'mind::tests::require_instance_is_the_one_check_admission_and_the_daemon_share'
|
|
Command = 'cargo test -p huginn-mind --lib'
|
|
File = 'crates/huginn-mind/src/mind.rs'
|
|
Old = ' if declared != self.instance() {'
|
|
New = ' if declared.0.as_bytes().first() != self.instance().0.as_bytes().first() {'
|
|
}
|
|
@{
|
|
Id = 'D1L3'
|
|
Rule = 'It runs on every declared name, not only on one long enough to look suspicious.'
|
|
Test = 'mind::tests::require_instance_is_the_one_check_admission_and_the_daemon_share'
|
|
Command = 'cargo test -p huginn-mind --lib'
|
|
File = 'crates/huginn-mind/src/mind.rs'
|
|
Old = ' if declared != self.instance() {'
|
|
New = ' if declared.0.len() > self.instance().0.len() && declared != self.instance() {'
|
|
}
|
|
@{
|
|
Id = 'D1L4'
|
|
Rule = 'It compares the names, not whether one begins with the other.'
|
|
Test = 'mind::tests::require_instance_is_the_one_check_admission_and_the_daemon_share'
|
|
Command = 'cargo test -p huginn-mind --lib'
|
|
File = 'crates/huginn-mind/src/mind.rs'
|
|
Old = ' if declared != self.instance() {'
|
|
New = ' if !declared.0.starts_with(&self.instance().0) {'
|
|
}
|
|
@{
|
|
Id = 'D1L5'
|
|
Rule = 'It compares the names as written: a slug may carry uppercase, so two names differing in case are two minds.'
|
|
Test = 'mind::tests::require_instance_is_the_one_check_admission_and_the_daemon_share'
|
|
Command = 'cargo test -p huginn-mind --lib'
|
|
File = 'crates/huginn-mind/src/mind.rs'
|
|
Old = ' if declared != self.instance() {'
|
|
New = ' if !declared.0.eq_ignore_ascii_case(&self.instance().0) {'
|
|
}
|
|
@{
|
|
Id = 'D1L6'
|
|
Rule = 'It compares the names as written: `_` and `-` are both legal inside a label, so folding one into the other answers a different mind''s name for this one.'
|
|
Test = 'mind::tests::require_instance_is_the_one_check_admission_and_the_daemon_share'
|
|
Command = 'cargo test -p huginn-mind --lib'
|
|
File = 'crates/huginn-mind/src/mind.rs'
|
|
Old = ' if declared != self.instance() {'
|
|
New = ' if declared.0.replace(''_'', "-") != self.instance().0.replace(''_'', "-") {'
|
|
}
|
|
@{
|
|
Id = 'D1L7'
|
|
Rule = 'It compares the names as written: `.` joins labels and `-` sits inside one, so folding the join into the separator answers a different mind''s name for this one.'
|
|
Test = 'mind::tests::require_instance_is_the_one_check_admission_and_the_daemon_share'
|
|
Command = 'cargo test -p huginn-mind --lib'
|
|
File = 'crates/huginn-mind/src/mind.rs'
|
|
Old = ' if declared != self.instance() {'
|
|
New = ' if declared.0.replace(''.'', "-") != self.instance().0.replace(''.'', "-") {'
|
|
}
|
|
@{
|
|
Id = 'D1N'
|
|
Rule = 'The refusal names which mind refused, so an agent can act on the field rather than guess.'
|
|
Test = 'mind::tests::require_instance_is_the_one_check_admission_and_the_daemon_share'
|
|
Command = 'cargo test -p huginn-mind --lib'
|
|
File = 'crates/huginn-mind/src/mind.rs'
|
|
Old = ' mind: self.instance().0.clone(),'
|
|
New = ' mind: declared.0.clone(),'
|
|
}
|
|
@{
|
|
Id = 'D1D'
|
|
Rule = 'One check, two callers: the daemon''s reads are refused by the same function admission asks.'
|
|
Test = 'daemon::tests::a_read_or_a_write_naming_another_instance_is_refused_by_the_mind_and_writes_nothing'
|
|
File = 'crates/huginn-mind/src/mind.rs'
|
|
Old = @'
|
|
if declared != self.instance() {
|
|
return Err(MindRefusal::ForeignInstance {
|
|
declared: declared.0.clone(),
|
|
mind: self.instance().0.clone(),
|
|
});
|
|
}
|
|
Ok(())
|
|
'@
|
|
New = @'
|
|
let _ = declared;
|
|
Ok(())
|
|
'@
|
|
}
|
|
@{
|
|
Id = 'D1DL'
|
|
Rule = 'The same comparison, reached the daemon''s way: a read naming a name of the mind''s own length is refused too.'
|
|
Test = 'daemon::tests::a_read_or_a_write_naming_another_instance_is_refused_by_the_mind_and_writes_nothing'
|
|
File = 'crates/huginn-mind/src/mind.rs'
|
|
Old = ' if declared != self.instance() {'
|
|
New = ' if declared.0.len() != self.instance().0.len() {'
|
|
}
|
|
@{
|
|
Id = 'D1DL2'
|
|
Rule = 'And case, the daemon''s way: the daemon''s own fixtures carry a name differing from the mind''s in case alone.'
|
|
Test = 'daemon::tests::a_read_or_a_write_naming_another_instance_is_refused_by_the_mind_and_writes_nothing'
|
|
File = 'crates/huginn-mind/src/mind.rs'
|
|
Old = ' if declared != self.instance() {'
|
|
New = ' if !declared.0.eq_ignore_ascii_case(&self.instance().0) {'
|
|
}
|
|
@{
|
|
Id = 'N3a'
|
|
Rule = 'N3: the comparison folds nothing; `_` and `.` stay distinct on both sides.'
|
|
Test = 'mind::tests::every_separator_variant_of_a_declared_name_is_foreign_not_the_mind'
|
|
Command = 'cargo test -p huginn-mind --lib'
|
|
File = 'crates/huginn-mind/src/mind.rs'
|
|
Old = ' if declared != self.instance() {'
|
|
New = ' if declared.0.replace(''_'', ".") != self.instance().0.replace(''_'', ".") {'
|
|
}
|
|
@{
|
|
Id = 'N3b'
|
|
Rule = 'N3: the comparison folds nothing on the mind''s own side alone; `_` and `-` stay distinct there too.'
|
|
Test = 'mind::tests::every_separator_variant_of_a_declared_name_is_foreign_not_the_mind'
|
|
Command = 'cargo test -p huginn-mind --lib'
|
|
File = 'crates/huginn-mind/src/mind.rs'
|
|
Old = ' if declared != self.instance() {'
|
|
New = ' if declared.0 != self.instance().0.replace(''_'', "-") {'
|
|
}
|
|
@{
|
|
Id = 'N3c'
|
|
Rule = 'N3: a leading or trailing `-` is part of the name, not padding `trim_matches` may strip before comparing.'
|
|
Test = 'mind::tests::every_separator_variant_of_a_declared_name_is_foreign_not_the_mind'
|
|
Command = 'cargo test -p huginn-mind --lib'
|
|
File = 'crates/huginn-mind/src/mind.rs'
|
|
Old = ' if declared != self.instance() {'
|
|
New = ' if declared.0.trim_matches(''-'') != self.instance().0.trim_matches(''-'') {'
|
|
}
|
|
@{
|
|
Id = 'N3d'
|
|
Rule = 'N3: a run of `--` is two hyphens, not one collapsed by the comparison before it runs.'
|
|
Test = 'mind::tests::every_separator_variant_of_a_declared_name_is_foreign_not_the_mind'
|
|
Command = 'cargo test -p huginn-mind --lib'
|
|
File = 'crates/huginn-mind/src/mind.rs'
|
|
Old = ' if declared != self.instance() {'
|
|
New = ' if declared.0.replace("--", "-") != self.instance().0.replace("--", "-") {'
|
|
}
|
|
@{
|
|
Id = 'S3wide'
|
|
Rule = 'The grammar check runs on the declared bytes as given: nothing folds a fullwidth character to its plain ASCII form before asking the leaf''s Slug::validate_slug whether the name is grammatical.'
|
|
Test = 'daemon::tests::a_declared_instance_outside_the_grammar_is_refused_by_name_before_the_identity_check'
|
|
Command = 'cargo test -p huginn-daemon --lib'
|
|
File = 'crates/huginn-mind/src/mind.rs'
|
|
Old = @'
|
|
fn require_grammatical_slug(field: &str, declared: &Slug) -> Result<(), MindRefusal> {
|
|
declared.validate_slug().map_err(|_| {
|
|
MindRefusal::Document(epiphany_pipeline::PipelineRefusal::InvalidFormat {
|
|
field: field.into(),
|
|
value: declared.0.clone(),
|
|
})
|
|
})
|
|
}
|
|
'@
|
|
New = @'
|
|
fn require_grammatical_slug(field: &str, declared: &Slug) -> Result<(), MindRefusal> {
|
|
let folded = Slug(
|
|
declared
|
|
.0
|
|
.chars()
|
|
.map(|c| match c as u32 {
|
|
0xFF01..=0xFF5E => char::from_u32(c as u32 - 0xFEE0).unwrap_or(c),
|
|
_ => c,
|
|
})
|
|
.collect(),
|
|
);
|
|
folded.validate_slug().map_err(|_| {
|
|
MindRefusal::Document(epiphany_pipeline::PipelineRefusal::InvalidFormat {
|
|
field: field.into(),
|
|
value: declared.0.clone(),
|
|
})
|
|
})
|
|
}
|
|
'@
|
|
}
|
|
# Residue S2: N1's door, `require_grammatical_slug`, had no mutation
|
|
# entry for two of its three callers. `open`'s deletion is covered by
|
|
# N1's own escape test; `open_with`'s survived all 81 tests before
|
|
# this batch added one that names it; `require_instance`'s is covered
|
|
# the same way, since neither caller's test constructs an ungrammatical
|
|
# name the other way.
|
|
@{
|
|
Id = 'N1open'
|
|
Rule = 'N1: `open` checks the declared name''s grammar before it ever joins a path from it.'
|
|
Test = 'mind::tests::a_slug_outside_the_grammar_cannot_escape_the_state_root'
|
|
Command = 'cargo test -p huginn-mind --lib'
|
|
File = 'crates/huginn-mind/src/mind.rs'
|
|
Old = @'
|
|
pub fn open(state_root: &Path, instance: &Slug) -> Result<Self, MindRefusal> {
|
|
require_grammatical_slug("instance", instance)?;
|
|
let path = Self::path_for(state_root, instance);
|
|
'@
|
|
New = @'
|
|
pub fn open(state_root: &Path, instance: &Slug) -> Result<Self, MindRefusal> {
|
|
let path = Self::path_for(state_root, instance);
|
|
'@
|
|
}
|
|
@{
|
|
Id = 'N1openwith'
|
|
Rule = 'N1: `open_with` checks the declared name''s grammar too, for every store already in hand and not only for one `open` derived a path for.'
|
|
Test = 'mind::tests::open_with_refuses_a_declared_instance_outside_the_grammar'
|
|
Command = 'cargo test -p huginn-mind --lib'
|
|
File = 'crates/huginn-mind/src/mind.rs'
|
|
Old = @'
|
|
pub fn open_with(store: S, instance: &Slug) -> Result<Self, MindRefusal> {
|
|
require_grammatical_slug("instance", instance)?;
|
|
let raw = store.pull_all().map_err(unavailable)?;
|
|
'@
|
|
New = @'
|
|
pub fn open_with(store: S, instance: &Slug) -> Result<Self, MindRefusal> {
|
|
let raw = store.pull_all().map_err(unavailable)?;
|
|
'@
|
|
}
|
|
@{
|
|
Id = 'N1requireinstance'
|
|
Rule = 'N1: `require_instance` checks the declared name''s grammar before comparing it to the mind''s own, so an ungrammatical name is refused by name rather than merely being foreign.'
|
|
Test = 'mind::tests::require_instance_refuses_a_declared_name_outside_the_grammar'
|
|
Command = 'cargo test -p huginn-mind --lib'
|
|
File = 'crates/huginn-mind/src/mind.rs'
|
|
Old = @'
|
|
pub fn require_instance(&self, declared: &Slug) -> Result<(), MindRefusal> {
|
|
require_grammatical_slug("declared", declared)?;
|
|
if declared != self.instance() {
|
|
'@
|
|
New = @'
|
|
pub fn require_instance(&self, declared: &Slug) -> Result<(), MindRefusal> {
|
|
if declared != self.instance() {
|
|
'@
|
|
}
|
|
@{
|
|
Id = 'S4fold'
|
|
Rule = 'Residue S4: the grammar check runs on the declared bytes as given: nothing folds a Unicode hyphen (U+2010) to plain ASCII `-` before asking Slug::validate_slug whether the name is grammatical.'
|
|
Test = 'mind::tests::a_unicode_hyphen_is_not_folded_before_the_grammar_check'
|
|
Command = 'cargo test -p huginn-mind --lib'
|
|
File = 'crates/huginn-mind/src/mind.rs'
|
|
Old = @'
|
|
fn require_grammatical_slug(field: &str, declared: &Slug) -> Result<(), MindRefusal> {
|
|
declared.validate_slug().map_err(|_| {
|
|
MindRefusal::Document(epiphany_pipeline::PipelineRefusal::InvalidFormat {
|
|
field: field.into(),
|
|
value: declared.0.clone(),
|
|
})
|
|
})
|
|
}
|
|
'@
|
|
New = @'
|
|
fn require_grammatical_slug(field: &str, declared: &Slug) -> Result<(), MindRefusal> {
|
|
let folded = Slug(declared.0.chars().map(|c| if c == '\u{2010}' { '-' } else { c }).collect());
|
|
folded.validate_slug().map_err(|_| {
|
|
MindRefusal::Document(epiphany_pipeline::PipelineRefusal::InvalidFormat {
|
|
field: field.into(),
|
|
value: declared.0.clone(),
|
|
})
|
|
})
|
|
}
|
|
'@
|
|
}
|
|
@{
|
|
Id = 'D2'
|
|
Rule = 'Rulings 14 and 18 on the wire: the daemon passes the declared instance to the mind as the client sent it.'
|
|
Test = 'daemon::tests::a_read_or_a_write_naming_another_instance_is_refused_by_the_mind_and_writes_nothing'
|
|
File = 'crates/huginn-daemon/src/daemon.rs'
|
|
Old = @'
|
|
HuginnMindRequest::Admit(batch) => {
|
|
let outcome = self.mind.admit(batch, now);
|
|
'@
|
|
New = @'
|
|
HuginnMindRequest::Admit(mut batch) => {
|
|
batch.instance = self.mind.instance().clone();
|
|
let outcome = self.mind.admit(batch, now);
|
|
'@
|
|
}
|
|
@{
|
|
Id = 'D2L'
|
|
Rule = 'Every read that names an instance is checked, not only the one that returns a page.'
|
|
Test = 'daemon::tests::a_read_or_a_write_naming_another_instance_is_refused_by_the_mind_and_writes_nothing'
|
|
File = 'crates/huginn-daemon/src/daemon.rs'
|
|
Old = ' && !matches!(request, HuginnMindRequest::Admit(_))'
|
|
New = ' && matches!(request, HuginnMindRequest::Query { .. })'
|
|
}
|
|
@{
|
|
Id = 'D3'
|
|
Rule = 'A refusal is data in the response, never a transport failure the client must parse out of a failure envelope.'
|
|
Test = 'serve::tests::a_malformed_envelope_is_answered_with_a_failure_and_touches_no_mind'
|
|
File = 'crates/huginn-daemon/src/serve.rs'
|
|
Old = ' let reply = encode_or_fail(&message_id, operation, &response, &runtime_id);'
|
|
New = @'
|
|
if let HuginnMindResponse::Refused(refusal) = &response {
|
|
return encode_failure(
|
|
&message_id,
|
|
operation,
|
|
&crate::envelope::OperationFailure {
|
|
code: "refused".into(),
|
|
message: format!("{refusal}"),
|
|
},
|
|
&runtime_id,
|
|
);
|
|
}
|
|
let reply = encode_or_fail(&message_id, operation, &response, &runtime_id);
|
|
'@
|
|
}
|
|
@{
|
|
Id = 'D3L'
|
|
Rule = 'The envelope''s status is derived from the response, so a refusal cannot go out as an acceptance.'
|
|
Test = 'wire::tests::the_wire_vocabulary_is_the_minds_methods_and_status_is_derived_from_the_response'
|
|
Command = 'cargo test -p huginn-mind --lib'
|
|
File = 'crates/huginn-mind/src/wire.rs'
|
|
Old = ' Self::Refused(_) | Self::Admit(PipelineAdmissionOutcome::Refused(_)) => "rejected",'
|
|
New = ' Self::Admit(PipelineAdmissionOutcome::Refused(_)) => "rejected",'
|
|
}
|
|
@{
|
|
Id = 'D4'
|
|
Rule = 'An envelope the daemon cannot decode touches no mind; it is answered with its own failure code.'
|
|
Test = 'serve::tests::a_malformed_envelope_is_answered_with_a_failure_and_touches_no_mind'
|
|
File = 'crates/huginn-daemon/src/envelope.rs'
|
|
Old = @'
|
|
let request: HuginnMindRequest = rmp_serde::from_slice(&bytes)
|
|
.map_err(|error| OperationFailure::new("payload-not-a-request", error.to_string()))?;
|
|
'@
|
|
New = @'
|
|
let request: HuginnMindRequest = rmp_serde::from_slice(&bytes).unwrap_or(HuginnMindRequest::Whoami);
|
|
'@
|
|
}
|
|
@{
|
|
Id = 'D4L'
|
|
Rule = 'The envelope is addressed to this service, and a request for another one is refused rather than served.'
|
|
Test = 'serve::tests::a_malformed_envelope_is_answered_with_a_failure_and_touches_no_mind'
|
|
File = 'crates/huginn-daemon/src/envelope.rs'
|
|
Old = @'
|
|
if service_id != MIND_SERVICE_ID {
|
|
return Err(OperationFailure::new("wrong-service", format!("{service_id} is not {MIND_SERVICE_ID}")));
|
|
}
|
|
'@
|
|
New = @'
|
|
let _ = service_id;
|
|
'@
|
|
}
|
|
@{
|
|
Id = 'D5'
|
|
Rule = 'The envelope''s operation string is checked against the decoded payload, never trusted.'
|
|
Test = 'serve::tests::a_malformed_envelope_is_answered_with_a_failure_and_touches_no_mind'
|
|
File = 'crates/huginn-daemon/src/envelope.rs'
|
|
Old = @'
|
|
if operation != request.operation() {
|
|
return Err(OperationFailure::new(
|
|
"operation-mismatch",
|
|
format!("the envelope says {operation} and the payload is {}", request.operation()),
|
|
));
|
|
}
|
|
'@
|
|
New = @'
|
|
let _ = operation;
|
|
'@
|
|
}
|
|
@{
|
|
Id = 'D5L'
|
|
Rule = 'The operation is checked as the name it is, not as a shape that happens to match.'
|
|
Test = 'serve::tests::a_malformed_envelope_is_answered_with_a_failure_and_touches_no_mind'
|
|
File = 'crates/huginn-daemon/src/envelope.rs'
|
|
Old = ' if operation != request.operation() {'
|
|
New = ' if operation.len() != request.operation().len() {'
|
|
}
|
|
@{
|
|
Id = 'D20'
|
|
Rule = 'An answer larger than one send can carry is refused by name, not handed to a send that fails silently.'
|
|
Test = 'serve::tests::an_answer_too_large_for_one_send_is_a_typed_refusal_that_reaches_the_client'
|
|
File = 'crates/huginn-daemon/src/serve.rs'
|
|
Old = ' if encoded <= MAX_RESPONSE_BYTES {'
|
|
New = ' if true {'
|
|
}
|
|
@{
|
|
Id = 'D20L'
|
|
Rule = 'It is measured against the window the hub was configured with, not against a number chosen to admit it.'
|
|
Test = 'serve::tests::an_answer_too_large_for_one_send_is_a_typed_refusal_that_reaches_the_client'
|
|
File = 'crates/huginn-daemon/src/serve.rs'
|
|
Old = ' if encoded <= MAX_RESPONSE_BYTES {'
|
|
New = ' if encoded <= MAX_RESPONSE_BYTES * 4 {'
|
|
}
|
|
@{
|
|
Id = 'D20L2'
|
|
Rule = 'The refusal carries the answer''s own encoded size, so a caller can tell how far it overshot.'
|
|
Test = 'serve::tests::an_answer_too_large_for_one_send_is_a_typed_refusal_that_reaches_the_client'
|
|
File = 'crates/huginn-daemon/src/serve.rs'
|
|
Old = ' bytes: encoded,'
|
|
New = ' bytes: MAX_RESPONSE_BYTES,'
|
|
}
|
|
@{
|
|
Id = 'D20L3'
|
|
Rule = 'And it carries the limit itself, not the size again, so the two are not one number twice.'
|
|
Test = 'serve::tests::an_answer_too_large_for_one_send_is_a_typed_refusal_that_reaches_the_client'
|
|
File = 'crates/huginn-daemon/src/serve.rs'
|
|
Old = ' limit: MAX_RESPONSE_BYTES,'
|
|
New = ' limit: encoded,'
|
|
}
|
|
@{
|
|
Id = 'D20L4'
|
|
Rule = 'The limit itself is deliverable: the comparison admits an answer of exactly the window''s size, as the transport does.'
|
|
Test = 'serve::tests::the_gates_boundary_is_the_transports_boundary_byte_for_byte'
|
|
File = 'crates/huginn-daemon/src/serve.rs'
|
|
Old = ' if encoded <= MAX_RESPONSE_BYTES {'
|
|
New = ' if encoded < MAX_RESPONSE_BYTES {'
|
|
}
|
|
@{
|
|
Id = 'D20L5'
|
|
Rule = 'What is measured is the encoded envelope the hub fragments, not the payload string inside it.'
|
|
Test = 'serve::tests::the_gates_boundary_is_the_transports_boundary_byte_for_byte'
|
|
File = 'crates/huginn-daemon/src/serve.rs'
|
|
Old = @'
|
|
let encoded = match encode_cultnet_message_to_vec(&reply, CultNetWireContract::CultNetSchemaV0) {
|
|
Ok(bytes) => bytes.len() as u64,
|
|
'@
|
|
New = @'
|
|
let encoded = match encode_cultnet_message_to_vec(&reply, CultNetWireContract::CultNetSchemaV0) {
|
|
Ok(bytes) => match &reply {
|
|
CultNetMessage::OperationResponse { payload, .. } => payload.len() as u64,
|
|
_ => bytes.len() as u64,
|
|
},
|
|
'@
|
|
}
|
|
@{
|
|
Id = 'D20L6'
|
|
Rule = 'What is measured holds for more than one envelope shape: a longer `message_id` changes the encoded envelope, so a formula that hard-codes one length''s overhead is wrong at another.'
|
|
Test = 'serve::tests::the_gates_boundary_holds_for_a_second_message_id_length'
|
|
File = 'crates/huginn-daemon/src/serve.rs'
|
|
Old = @'
|
|
let encoded = match encode_cultnet_message_to_vec(&reply, CultNetWireContract::CultNetSchemaV0) {
|
|
Ok(bytes) => bytes.len() as u64,
|
|
'@
|
|
New = @'
|
|
let encoded = match encode_cultnet_message_to_vec(&reply, CultNetWireContract::CultNetSchemaV0) {
|
|
Ok(bytes) => match &reply {
|
|
CultNetMessage::OperationResponse { payload, .. } => payload.len() as u64 + 231,
|
|
_ => bytes.len() as u64,
|
|
},
|
|
'@
|
|
}
|
|
@{
|
|
Id = 'N4a'
|
|
Rule = 'N4: what is measured holds for more than `message_id`''s length; `operation` and the runtime id are in the encoded envelope too, so a formula of `message_id.len()` alone -- even one shaped to survive a longer id, `+228+id.len()+(id.len()>31)` -- is wrong once the operation or runtime id it never looked at changes length.'
|
|
Test = 'serve::tests::the_gates_boundary_holds_across_operation_and_runtime_id'
|
|
Command = 'cargo test -p huginn-daemon --lib'
|
|
File = 'crates/huginn-daemon/src/serve.rs'
|
|
Old = @'
|
|
let encoded = match encode_cultnet_message_to_vec(&reply, CultNetWireContract::CultNetSchemaV0) {
|
|
Ok(bytes) => bytes.len() as u64,
|
|
'@
|
|
New = @'
|
|
let encoded = match encode_cultnet_message_to_vec(&reply, CultNetWireContract::CultNetSchemaV0) {
|
|
Ok(bytes) => match &reply {
|
|
CultNetMessage::OperationResponse { payload, .. } => {
|
|
payload.len() as u64 + 228 + message_id.len() as u64 + (message_id.len() > 31) as u64
|
|
}
|
|
_ => bytes.len() as u64,
|
|
},
|
|
'@
|
|
}
|
|
@{
|
|
Id = 'N4b'
|
|
Rule = 'N4: a coincidence caught the same way -- `228+id.len()*38/37` fits both of the suite''s `message_id` lengths (three and forty bytes) by the ratio between them, not by measuring the envelope, so it is wrong once the operation or the runtime id changes the envelope''s size at either length.'
|
|
Test = 'serve::tests::the_gates_boundary_holds_across_operation_and_runtime_id'
|
|
Command = 'cargo test -p huginn-daemon --lib'
|
|
File = 'crates/huginn-daemon/src/serve.rs'
|
|
Old = @'
|
|
let encoded = match encode_cultnet_message_to_vec(&reply, CultNetWireContract::CultNetSchemaV0) {
|
|
Ok(bytes) => bytes.len() as u64,
|
|
'@
|
|
New = @'
|
|
let encoded = match encode_cultnet_message_to_vec(&reply, CultNetWireContract::CultNetSchemaV0) {
|
|
Ok(bytes) => match &reply {
|
|
CultNetMessage::OperationResponse { payload, .. } => {
|
|
payload.len() as u64 + 228 + (message_id.len() as u64 * 38 / 37)
|
|
}
|
|
_ => bytes.len() as u64,
|
|
},
|
|
'@
|
|
}
|
|
@{
|
|
Id = 'N4c'
|
|
Rule = 'Residue S1: what is measured holds for the operation and the runtime id independently, not merely for the two moving together as N4a and N4b probed them; a formula that adds a term for the operation''s length but drops the runtime id -- `228+id+(id>31)+(op.len()-4)*3/2` -- is wrong once a fixture holds the operation long and the runtime id short.'
|
|
Test = 'serve::tests::the_gates_boundary_holds_when_operation_and_runtime_id_vary_independently'
|
|
Command = 'cargo test -p huginn-daemon --lib'
|
|
File = 'crates/huginn-daemon/src/serve.rs'
|
|
Old = @'
|
|
let encoded = match encode_cultnet_message_to_vec(&reply, CultNetWireContract::CultNetSchemaV0) {
|
|
Ok(bytes) => bytes.len() as u64,
|
|
'@
|
|
New = @'
|
|
let encoded = match encode_cultnet_message_to_vec(&reply, CultNetWireContract::CultNetSchemaV0) {
|
|
Ok(bytes) => match &reply {
|
|
CultNetMessage::OperationResponse { payload, .. } => {
|
|
payload.len() as u64
|
|
+ 228
|
|
+ message_id.len() as u64
|
|
+ (message_id.len() > 31) as u64
|
|
+ (operation.len() as u64).saturating_sub(4) * 3 / 2
|
|
}
|
|
_ => bytes.len() as u64,
|
|
},
|
|
'@
|
|
}
|
|
@{
|
|
Id = 'N4d'
|
|
Rule = 'Residue S1: the same, the other way round; a formula that adds a term for the runtime id but drops the operation -- `228+id+(id>31)+3*(rt.len()-16)` -- is wrong once a fixture holds the runtime id long and the operation short.'
|
|
Test = 'serve::tests::the_gates_boundary_holds_when_operation_and_runtime_id_vary_independently'
|
|
Command = 'cargo test -p huginn-daemon --lib'
|
|
File = 'crates/huginn-daemon/src/serve.rs'
|
|
Old = @'
|
|
let encoded = match encode_cultnet_message_to_vec(&reply, CultNetWireContract::CultNetSchemaV0) {
|
|
Ok(bytes) => bytes.len() as u64,
|
|
'@
|
|
New = @'
|
|
let encoded = match encode_cultnet_message_to_vec(&reply, CultNetWireContract::CultNetSchemaV0) {
|
|
Ok(bytes) => match &reply {
|
|
CultNetMessage::OperationResponse { payload, .. } => {
|
|
payload.len() as u64
|
|
+ 228
|
|
+ message_id.len() as u64
|
|
+ (message_id.len() > 31) as u64
|
|
+ 3 * (runtime_id.len() as u64).saturating_sub(16)
|
|
}
|
|
_ => bytes.len() as u64,
|
|
},
|
|
'@
|
|
}
|
|
@{
|
|
Id = 'D21'
|
|
Rule = 'The refusal rides the response schema like every other refusal, not a failure envelope the client must parse apart.'
|
|
Test = 'serve::tests::an_answer_too_large_for_one_send_is_a_typed_refusal_that_reaches_the_client'
|
|
File = 'crates/huginn-daemon/src/serve.rs'
|
|
Old = @'
|
|
let refusal = HuginnMindResponse::Refused(MindRefusal::ResponseTooLarge {
|
|
bytes: encoded,
|
|
limit: MAX_RESPONSE_BYTES,
|
|
});
|
|
encode_or_fail(message_id, operation, &refusal, runtime_id)
|
|
'@
|
|
New = @'
|
|
encode_failure(
|
|
message_id,
|
|
operation,
|
|
&crate::envelope::OperationFailure {
|
|
code: "response-too-large".into(),
|
|
message: format!("{encoded} bytes against a {MAX_RESPONSE_BYTES} limit"),
|
|
},
|
|
runtime_id,
|
|
)
|
|
'@
|
|
}
|
|
@{
|
|
Id = 'D21L'
|
|
Rule = 'It echoes the client''s own correlation key, so a refusal can be matched to the request that earned it.'
|
|
Test = 'serve::tests::an_answer_too_large_for_one_send_is_a_typed_refusal_that_reaches_the_client'
|
|
File = 'crates/huginn-daemon/src/serve.rs'
|
|
Old = ' encode_or_fail(message_id, operation, &refusal, runtime_id)'
|
|
New = ' encode_or_fail("response-too-large", operation, &refusal, runtime_id)'
|
|
}
|
|
@{
|
|
Id = 'D22'
|
|
Rule = 'The window the gate measures against is the window the hub carries: a smaller one sends nothing and says nothing.'
|
|
Test = 'serve::tests::an_answer_too_large_for_one_send_is_a_typed_refusal_that_reaches_the_client'
|
|
File = 'crates/huginn-daemon/src/serve.rs'
|
|
Old = ' options.max_pending_reliable_packets = Some(MAX_PENDING_RELIABLE_PACKETS);'
|
|
New = ' options.max_pending_reliable_packets = Some(MAX_PENDING_RELIABLE_PACKETS / 2);'
|
|
}
|
|
@{
|
|
Id = 'D22L'
|
|
Rule = 'Not merely close to it: a window short by a few dozen packets still drops an answer the gate admitted.'
|
|
Test = 'serve::tests::an_answer_too_large_for_one_send_is_a_typed_refusal_that_reaches_the_client'
|
|
File = 'crates/huginn-daemon/src/serve.rs'
|
|
Old = ' options.max_pending_reliable_packets = Some(MAX_PENDING_RELIABLE_PACKETS);'
|
|
New = ' options.max_pending_reliable_packets = Some(MAX_PENDING_RELIABLE_PACKETS - 64);'
|
|
}
|
|
@{
|
|
Id = 'D22L2'
|
|
Rule = 'The fragment size is the window''s other half: a smaller one carries fewer bytes in the same packet count.'
|
|
Test = 'serve::tests::an_answer_too_large_for_one_send_is_a_typed_refusal_that_reaches_the_client'
|
|
File = 'crates/huginn-daemon/src/serve.rs'
|
|
Old = ' options.max_fragment_bytes = Some(MAX_FRAGMENT_BYTES);'
|
|
New = ' options.max_fragment_bytes = Some(MAX_FRAGMENT_BYTES - 64);'
|
|
}
|
|
@{
|
|
Id = 'D17'
|
|
Rule = 'A refusal `view` raised crosses the dispatch as itself, not rewrapped as unavailable.'
|
|
Test = 'daemon::tests::a_refusal_a_read_raised_is_the_answer_the_dispatch_returns_whole'
|
|
File = 'crates/huginn-daemon/src/daemon.rs'
|
|
Old = @'
|
|
HuginnMindRequest::View { id, .. } => match self.mind.view(&id) {
|
|
Ok(view) => HuginnMindResponse::View(view),
|
|
Err(refusal) => HuginnMindResponse::Refused(refusal),
|
|
},
|
|
'@
|
|
New = @'
|
|
HuginnMindRequest::View { id, .. } => match self.mind.view(&id) {
|
|
Ok(view) => HuginnMindResponse::View(view),
|
|
Err(refusal) => HuginnMindResponse::Refused(huginn_mind::MindRefusal::Unavailable {
|
|
detail: format!("{refusal}"),
|
|
}),
|
|
},
|
|
'@
|
|
}
|
|
@{
|
|
Id = 'D17L'
|
|
Rule = 'It is not swallowed into an empty answer either: a malformed reference is not an absent document.'
|
|
Test = 'daemon::tests::a_refusal_a_read_raised_is_the_answer_the_dispatch_returns_whole'
|
|
File = 'crates/huginn-daemon/src/daemon.rs'
|
|
Old = @'
|
|
Err(refusal) => HuginnMindResponse::Refused(refusal),
|
|
},
|
|
HuginnMindRequest::Query { query, .. } => match self.mind.query(&query) {
|
|
'@
|
|
New = @'
|
|
Err(_) => HuginnMindResponse::View(None),
|
|
},
|
|
HuginnMindRequest::Query { query, .. } => match self.mind.query(&query) {
|
|
'@
|
|
}
|
|
@{
|
|
Id = 'D18'
|
|
Rule = 'A refusal `query` raised crosses the dispatch as itself, with the mind''s own detail.'
|
|
Test = 'daemon::tests::a_refusal_a_read_raised_is_the_answer_the_dispatch_returns_whole'
|
|
File = 'crates/huginn-daemon/src/daemon.rs'
|
|
Old = @'
|
|
HuginnMindRequest::Query { query, .. } => match self.mind.query(&query) {
|
|
Ok(page) => HuginnMindResponse::Query(page),
|
|
Err(refusal) => HuginnMindResponse::Refused(refusal),
|
|
},
|
|
'@
|
|
New = @'
|
|
HuginnMindRequest::Query { query, .. } => match self.mind.query(&query) {
|
|
Ok(page) => HuginnMindResponse::Query(page),
|
|
Err(refusal) => HuginnMindResponse::Refused(huginn_mind::MindRefusal::Unavailable {
|
|
detail: format!("a query was refused: {refusal}"),
|
|
}),
|
|
},
|
|
'@
|
|
}
|
|
@{
|
|
Id = 'D18L'
|
|
Rule = 'Nor is it flattened into an empty page, which would read as a mind holding nothing.'
|
|
Test = 'daemon::tests::a_refusal_a_read_raised_is_the_answer_the_dispatch_returns_whole'
|
|
File = 'crates/huginn-daemon/src/daemon.rs'
|
|
Old = @'
|
|
Ok(page) => HuginnMindResponse::Query(page),
|
|
Err(refusal) => HuginnMindResponse::Refused(refusal),
|
|
'@
|
|
New = @'
|
|
Ok(page) => HuginnMindResponse::Query(page),
|
|
Err(_) => HuginnMindResponse::Query(huginn_mind::PipelineQueryPage { items: vec![], matched: 0 }),
|
|
'@
|
|
}
|
|
@{
|
|
Id = 'D19'
|
|
Rule = 'A refusal `history` raised crosses the dispatch as itself, not as another read''s refusal.'
|
|
Test = 'daemon::tests::a_refusal_a_read_raised_is_the_answer_the_dispatch_returns_whole'
|
|
File = 'crates/huginn-daemon/src/daemon.rs'
|
|
Old = @'
|
|
HuginnMindRequest::History { scope, .. } => match self.mind.history(&scope) {
|
|
Ok(views) => HuginnMindResponse::History(views),
|
|
Err(refusal) => HuginnMindResponse::Refused(refusal),
|
|
},
|
|
'@
|
|
New = @'
|
|
HuginnMindRequest::History { scope, .. } => match self.mind.history(&scope) {
|
|
Ok(views) => HuginnMindResponse::History(views),
|
|
Err(_) => HuginnMindResponse::Refused(huginn_mind::MindRefusal::Unavailable {
|
|
detail: "semantic query: the index is not wired (Cut 11)".into(),
|
|
}),
|
|
},
|
|
'@
|
|
}
|
|
@{
|
|
Id = 'D19L'
|
|
Rule = 'Nor is a history refusal swallowed into an empty history, which is the answer for a subject with no records.'
|
|
Test = 'daemon::tests::a_refusal_a_read_raised_is_the_answer_the_dispatch_returns_whole'
|
|
File = 'crates/huginn-daemon/src/daemon.rs'
|
|
Old = @'
|
|
Ok(views) => HuginnMindResponse::History(views),
|
|
Err(refusal) => HuginnMindResponse::Refused(refusal),
|
|
'@
|
|
New = @'
|
|
Ok(views) => HuginnMindResponse::History(views),
|
|
Err(_) => HuginnMindResponse::History(vec![]),
|
|
'@
|
|
}
|
|
@{
|
|
Id = 'D23'
|
|
Rule = 'A refusal `open_items` carries out of the reader crosses the dispatch as itself, not rewrapped as unavailable.'
|
|
Test = 'daemon::tests::a_refusal_open_items_raised_is_the_answer_the_dispatch_returns_whole'
|
|
File = 'crates/huginn-daemon/src/daemon.rs'
|
|
Old = @'
|
|
HuginnMindRequest::OpenItems { campaign, .. } => match self.mind.open_items(&campaign) {
|
|
Ok(items) => HuginnMindResponse::OpenItems(items),
|
|
Err(refusal) => HuginnMindResponse::Refused(refusal),
|
|
},
|
|
'@
|
|
New = @'
|
|
HuginnMindRequest::OpenItems { campaign, .. } => match self.mind.open_items(&campaign) {
|
|
Ok(items) => HuginnMindResponse::OpenItems(items),
|
|
Err(refusal) => HuginnMindResponse::Refused(huginn_mind::MindRefusal::Unavailable {
|
|
detail: format!("{refusal}"),
|
|
}),
|
|
},
|
|
'@
|
|
}
|
|
@{
|
|
Id = 'D23L'
|
|
Rule = 'Nor is it swallowed into an empty open set, which is what a healthy campaign with nothing open answers.'
|
|
Test = 'daemon::tests::a_refusal_open_items_raised_is_the_answer_the_dispatch_returns_whole'
|
|
File = 'crates/huginn-daemon/src/daemon.rs'
|
|
Old = @'
|
|
Ok(items) => HuginnMindResponse::OpenItems(items),
|
|
Err(refusal) => HuginnMindResponse::Refused(refusal),
|
|
'@
|
|
New = @'
|
|
Ok(items) => HuginnMindResponse::OpenItems(items),
|
|
Err(_) => HuginnMindResponse::OpenItems(huginn_mind::PipelineOpenItems {
|
|
questions: vec![],
|
|
findings: vec![],
|
|
follow_ups: vec![],
|
|
specs_without_report: vec![],
|
|
reports_without_verdict: vec![],
|
|
}),
|
|
'@
|
|
}
|
|
# S1 and S1d's fixture, `open_items_refuses_on_a_fault_inside_the_requested_campaign`,
|
|
# runs three faults in one test body: an orphan receipt, an undecodable
|
|
# document, and a document two receipts claim. N5, correcting an
|
|
# earlier claim here: neither mutant "dies on all three". S1d's own
|
|
# `New` exempts any detail containing "has no commit receipt" by
|
|
# construction, so the orphan block never fails under it; the test
|
|
# panics at the very next block, the undecodable document, and never
|
|
# reaches the third. S1 has no such exemption and is killed by the
|
|
# same first block its own widened check reaches, the orphan. Each
|
|
# mutant dies on the fault its own body actually mangles, not on all
|
|
# three the fixture happens to carry.
|
|
@{
|
|
Id = 'S1'
|
|
Rule = 'open_items refuses on a fault anywhere in the image it must read, not only on one outside the requested campaign.'
|
|
Test = 'daemon::tests::open_items_refuses_on_a_fault_inside_the_requested_campaign'
|
|
Command = 'cargo test -p huginn-daemon --lib'
|
|
File = 'crates/huginn-mind/src/query.rs'
|
|
Old = @'
|
|
let reader = Reader::new(self)?;
|
|
let views = reader
|
|
.views()?
|
|
.into_iter()
|
|
.filter(|view| root_and_local(&view.id.id.0).0 == campaign.0)
|
|
.collect::<Vec<_>>();
|
|
'@
|
|
New = @'
|
|
let views = match Reader::new(self).and_then(|reader| reader.views()) {
|
|
Ok(views) => views,
|
|
Err(MindRefusal::Unavailable { detail }) if detail.contains(campaign.0.as_str()) => Vec::new(),
|
|
Err(other) => return Err(other),
|
|
}
|
|
.into_iter()
|
|
.filter(|view| root_and_local(&view.id.id.0).0 == campaign.0)
|
|
.collect::<Vec<_>>();
|
|
'@
|
|
}
|
|
@{
|
|
Id = 'S1d'
|
|
Rule = 'It refuses on every kind of fault a document can carry, not only a missing receipt.'
|
|
Test = 'daemon::tests::open_items_refuses_on_a_fault_inside_the_requested_campaign'
|
|
Command = 'cargo test -p huginn-daemon --lib'
|
|
File = 'crates/huginn-mind/src/query.rs'
|
|
Old = @'
|
|
let reader = Reader::new(self)?;
|
|
let views = reader
|
|
.views()?
|
|
.into_iter()
|
|
.filter(|view| root_and_local(&view.id.id.0).0 == campaign.0)
|
|
.collect::<Vec<_>>();
|
|
'@
|
|
New = @'
|
|
let views = match Reader::new(self).and_then(|reader| reader.views()) {
|
|
Ok(views) => views,
|
|
Err(MindRefusal::Unavailable { detail }) if !detail.contains("has no commit receipt") => Vec::new(),
|
|
Err(other) => return Err(other),
|
|
}
|
|
.into_iter()
|
|
.filter(|view| root_and_local(&view.id.id.0).0 == campaign.0)
|
|
.collect::<Vec<_>>();
|
|
'@
|
|
}
|
|
@{
|
|
Id = 'D5L2'
|
|
Rule = 'The operation is compared as bytes: another casing of the name is another name.'
|
|
Test = 'serve::tests::a_malformed_envelope_is_answered_with_a_failure_and_touches_no_mind'
|
|
File = 'crates/huginn-daemon/src/envelope.rs'
|
|
Old = ' if operation != request.operation() {'
|
|
New = ' if !operation.eq_ignore_ascii_case(request.operation()) {'
|
|
}
|
|
@{
|
|
Id = 'D6'
|
|
Rule = 'The index never decides an outcome: a sink that fails does not refuse a batch the mind admitted.'
|
|
Test = 'daemon::tests::the_index_is_handed_every_landed_write_after_commit_and_never_decides_the_outcome'
|
|
File = 'crates/huginn-daemon/src/daemon.rs'
|
|
Old = @'
|
|
let refs = writes.iter().map(|write| write.id.0.clone()).collect::<Vec<_>>().join(", ");
|
|
eprintln!("huginn: the index refused the landed writes [{refs}]: {error:#}");
|
|
'@
|
|
New = @'
|
|
return HuginnMindResponse::Admit(PipelineAdmissionOutcome::Refused(
|
|
huginn_mind::MindRefusal::Unavailable { detail: format!("{error:#}") },
|
|
));
|
|
'@
|
|
}
|
|
@{
|
|
Id = 'D6L'
|
|
Rule = 'The index does not change the answer either: the outcome is the mind''s, whatever the sink did with it.'
|
|
Test = 'daemon::tests::the_index_is_handed_every_landed_write_after_commit_and_never_decides_the_outcome'
|
|
File = 'crates/huginn-daemon/src/daemon.rs'
|
|
Old = @'
|
|
let refs = writes.iter().map(|write| write.id.0.clone()).collect::<Vec<_>>().join(", ");
|
|
eprintln!("huginn: the index refused the landed writes [{refs}]: {error:#}");
|
|
'@
|
|
New = @'
|
|
return HuginnMindResponse::Admit(PipelineAdmissionOutcome::AlreadyAdmitted {
|
|
receipt_id: format!("index-unavailable: {error:#}"),
|
|
});
|
|
'@
|
|
}
|
|
@{
|
|
Id = 'D7'
|
|
Rule = 'The index is handed every landed write.'
|
|
Test = 'daemon::tests::the_index_is_handed_every_landed_write_after_commit_and_never_decides_the_outcome'
|
|
File = 'crates/huginn-daemon/src/daemon.rs'
|
|
Old = ' && let Err(error) = self.index.committed(&self.mind, writes)'
|
|
New = ' && let Err(error) = self.index.committed(&self.mind, &[])'
|
|
}
|
|
@{
|
|
Id = 'D7L'
|
|
Rule = 'Derived writes are landed writes: a ruling that answers a question hands the index two documents, not one.'
|
|
Test = 'daemon::tests::the_index_is_handed_every_landed_write_after_commit_and_never_decides_the_outcome'
|
|
File = 'crates/huginn-daemon/src/daemon.rs'
|
|
Old = ' && let Err(error) = self.index.committed(&self.mind, writes)'
|
|
New = ' && let Err(error) = self.index.committed(&self.mind, &writes[..1])'
|
|
}
|
|
@{
|
|
Id = 'D8'
|
|
Rule = 'Each reply goes to the session its request arrived on.'
|
|
Test = 'serve::tests::two_clients_get_their_own_replies_over_loopback'
|
|
File = 'crates/huginn-daemon/src/serve.rs'
|
|
Old = @'
|
|
let reply = answer(daemon, registry, message, Utc::now());
|
|
if let Err(error) = hub.send_schema_message(&session, &reply) {
|
|
'@
|
|
New = @'
|
|
let reply = answer(daemon, registry, message, Utc::now());
|
|
let session = hub.sessions().into_iter().next().unwrap_or(session);
|
|
if let Err(error) = hub.send_schema_message(&session, &reply) {
|
|
'@
|
|
}
|
|
@{
|
|
Id = 'D8L'
|
|
Rule = 'A reply goes to one session, not to everyone connected: another peer''s answer is not this peer''s to read.'
|
|
Test = 'serve::tests::two_clients_get_their_own_replies_over_loopback'
|
|
File = 'crates/huginn-daemon/src/serve.rs'
|
|
Old = @'
|
|
if let Err(error) = hub.send_schema_message(&session, &reply) {
|
|
eprintln!("huginn: {} did not receive its reply: {error:#}", session.remote_addr);
|
|
}
|
|
'@
|
|
New = @'
|
|
for session in hub.sessions() {
|
|
if let Err(error) = hub.send_schema_message(&session, &reply) {
|
|
eprintln!("huginn: {} did not receive its reply: {error:#}", session.remote_addr);
|
|
}
|
|
}
|
|
'@
|
|
}
|
|
@{
|
|
Id = 'D9'
|
|
Rule = 'The hub serves CultNet''s operation connection id and no other, so a peer speaking another protocol on the port never becomes a session.'
|
|
Test = 'serve::tests::two_clients_get_their_own_replies_over_loopback'
|
|
File = 'crates/huginn-daemon/src/serve.rs'
|
|
Old = ' let mut options = CultNetRudpServerHubOptions::new(runtime_id, socket, CULTNET_OPERATION_CONNECTION_ID);'
|
|
New = ' let mut options = CultNetRudpServerHubOptions::new(runtime_id, socket, 0x4355_4c55);'
|
|
}
|
|
@{
|
|
Id = 'D10'
|
|
Rule = '`whoami` is derived from the mind: `documents` counts pipeline documents, not every row the store holds.'
|
|
Test = 'daemon::tests::a_batch_round_trips_typed_through_handle_without_a_socket'
|
|
File = 'crates/huginn-mind/src/wire.rs'
|
|
Old = @'
|
|
} else if PipelineKind::ALL.iter().any(|kind| kind.type_id() == envelope.r#type) {
|
|
documents += 1;
|
|
}
|
|
'@
|
|
New = @'
|
|
} else {
|
|
documents += 1;
|
|
}
|
|
'@
|
|
}
|
|
@{
|
|
Id = 'D10L'
|
|
Rule = 'A mind says how many receipts it holds, so a reader can tell a mind that has admitted from one that has not.'
|
|
Test = 'daemon::tests::a_batch_round_trips_typed_through_handle_without_a_socket'
|
|
File = 'crates/huginn-mind/src/wire.rs'
|
|
Old = @'
|
|
if envelope.r#type == HuginnCommitReceipt::TYPE {
|
|
receipts += 1;
|
|
'@
|
|
New = @'
|
|
if envelope.r#type == HuginnCommitReceipt::TYPE {
|
|
receipts += 0;
|
|
'@
|
|
}
|
|
@{
|
|
Id = 'D11'
|
|
Rule = 'Ruling 15: a mind that will not open is refused, and no other mind is opened in its place.'
|
|
Test = 'daemon::tests::the_daemon_refuses_loudly_when_it_cannot_open_the_mind_and_binds_nothing'
|
|
File = 'crates/huginn-daemon/src/daemon.rs'
|
|
Old = ' Ok(Self { mind: Mind::open(state_root, instance)?, index: NoIndex })'
|
|
New = @'
|
|
let mind = match Mind::open(state_root, instance) {
|
|
Ok(mind) => mind,
|
|
Err(_) => Mind::open(&state_root.join("fallback"), instance)?,
|
|
};
|
|
Ok(Self { mind, index: NoIndex })
|
|
'@
|
|
}
|
|
@{
|
|
Id = 'D11L'
|
|
Rule = 'Every refusal of the opener is a refusal to serve, not only the held lock: a store naming another instance is not this daemon''s to open.'
|
|
Test = 'daemon::tests::the_daemon_refuses_loudly_when_it_cannot_open_the_mind_and_binds_nothing'
|
|
File = 'crates/huginn-daemon/src/daemon.rs'
|
|
Old = ' Ok(Self { mind: Mind::open(state_root, instance)?, index: NoIndex })'
|
|
New = @'
|
|
let mind = match Mind::open(state_root, instance) {
|
|
Ok(mind) => mind,
|
|
Err(held @ MindRefusal::MindAlreadyOwned { .. }) => return Err(held),
|
|
Err(_) => Mind::open(&state_root.join("fallback"), instance)?,
|
|
};
|
|
Ok(Self { mind, index: NoIndex })
|
|
'@
|
|
}
|
|
@{
|
|
Id = 'D12'
|
|
Rule = 'Ruling 15 as an order: the mind opens before anything binds, so a refused mind is reported as a refused mind and no socket is ever taken.'
|
|
Test = 'serve::tests::startup_opens_the_mind_before_it_binds_anything'
|
|
File = 'crates/huginn-daemon/src/serve.rs'
|
|
Old = @'
|
|
let daemon = Daemon::open(&options.state_root, &options.instance)?;
|
|
let hub = bind(options.bind, &daemon.runtime_id())?;
|
|
'@
|
|
New = @'
|
|
let hub = bind(options.bind, "huginn")?;
|
|
let daemon = Daemon::open(&options.state_root, &options.instance)?;
|
|
'@
|
|
}
|
|
@{
|
|
Id = 'D12L'
|
|
Rule = 'Tidying up afterwards is not the order: a socket taken before the mind opened was still taken, and the refusal still comes back as the port''s rather than the mind''s.'
|
|
Test = 'serve::tests::startup_opens_the_mind_before_it_binds_anything'
|
|
File = 'crates/huginn-daemon/src/serve.rs'
|
|
Old = @'
|
|
let daemon = Daemon::open(&options.state_root, &options.instance)?;
|
|
let hub = bind(options.bind, &daemon.runtime_id())?;
|
|
'@
|
|
New = @'
|
|
let hub = bind(options.bind, "huginn")?;
|
|
let daemon = match Daemon::open(&options.state_root, &options.instance) {
|
|
Ok(daemon) => daemon,
|
|
Err(refusal) => {
|
|
drop(hub);
|
|
return Err(refusal.into());
|
|
}
|
|
};
|
|
let hub = bind(options.bind, &daemon.runtime_id())?;
|
|
'@
|
|
}
|
|
@{
|
|
Id = 'D13'
|
|
Rule = 'The wire vocabulary is the mind''s methods: one operation name per method, and it is that method''s name.'
|
|
Test = 'wire::tests::the_wire_vocabulary_is_the_minds_methods_and_status_is_derived_from_the_response'
|
|
Command = 'cargo test -p huginn-mind --lib'
|
|
File = 'crates/huginn-mind/src/wire.rs'
|
|
Old = ' Self::History { .. } => "history",'
|
|
New = ' Self::History { .. } => "query",'
|
|
}
|
|
@{
|
|
Id = 'D13L'
|
|
Rule = 'The operation name is the method''s spelling, so a client reading `Mind`''s surface can address it without a translation table.'
|
|
Test = 'wire::tests::the_wire_vocabulary_is_the_minds_methods_and_status_is_derived_from_the_response'
|
|
Command = 'cargo test -p huginn-mind --lib'
|
|
File = 'crates/huginn-mind/src/wire.rs'
|
|
Old = ' Self::OpenItems { .. } => "open_items",'
|
|
New = ' Self::OpenItems { .. } => "openItems",'
|
|
}
|
|
@{
|
|
Id = 'D14'
|
|
Rule = 'The published request schema equals its derivation, byte for byte.'
|
|
Test = 'wire::tests::published_wire_schemas_match_derivation'
|
|
Command = 'cargo test -p huginn-mind --lib'
|
|
File = 'schemas/cultnet/huginn.mind_request.v1.schema.json'
|
|
Old = ' "title": "HuginnMindRequest",'
|
|
New = ' "title": "HuginnMindRequest",'
|
|
}
|
|
@{
|
|
Id = 'D14L'
|
|
Rule = 'Both files are pinned, not one: the response schema is derived too, and a hand edit to it is the same drift.'
|
|
Test = 'wire::tests::published_wire_schemas_match_derivation'
|
|
Command = 'cargo test -p huginn-mind --lib'
|
|
File = 'schemas/cultnet/huginn.mind_response.v1.schema.json'
|
|
Old = ' "title": "HuginnMindResponse",'
|
|
New = ' "title": "HuginnMindResponse v1",'
|
|
}
|
|
@{
|
|
Id = 'D15'
|
|
Rule = 'A replay is an answer, not a rejection: `AlreadyAdmitted` tells a client its batch is in the mind already.'
|
|
Test = 'envelope::tests::a_refusal_is_a_typed_response_not_a_transport_failure'
|
|
File = 'crates/huginn-mind/src/wire.rs'
|
|
Old = ' Self::Refused(_) | Self::Admit(PipelineAdmissionOutcome::Refused(_)) => "rejected",'
|
|
New = @'
|
|
Self::Refused(_)
|
|
| Self::Admit(PipelineAdmissionOutcome::Refused(_))
|
|
| Self::Admit(PipelineAdmissionOutcome::AlreadyAdmitted { .. }) => "rejected",
|
|
'@
|
|
}
|
|
@{
|
|
Id = 'D15L'
|
|
Rule = 'A conflict is an answer too: it names the identities that collided, which a rejection would throw away.'
|
|
Test = 'envelope::tests::a_refusal_is_a_typed_response_not_a_transport_failure'
|
|
File = 'crates/huginn-mind/src/wire.rs'
|
|
Old = ' Self::Refused(_) | Self::Admit(PipelineAdmissionOutcome::Refused(_)) => "rejected",'
|
|
New = @'
|
|
Self::Refused(_)
|
|
| Self::Admit(PipelineAdmissionOutcome::Refused(_))
|
|
| Self::Admit(PipelineAdmissionOutcome::Conflict { .. }) => "rejected",
|
|
'@
|
|
}
|
|
@{
|
|
Id = 'D16'
|
|
Rule = 'A message of another family is answered, not dropped: CultNet refuses an empty error string, so a silent arm hangs the client.'
|
|
Test = 'serve::tests::a_malformed_envelope_is_answered_with_a_failure_and_touches_no_mind'
|
|
File = 'crates/huginn-daemon/src/serve.rs'
|
|
Old = @'
|
|
_ => CultNetMessage::Error {
|
|
error: format!(
|
|
"{MIND_SERVICE_ID} answers cultnet.operation_request.v0 and cultnet.schema_catalog_request.v0"
|
|
),
|
|
},
|
|
'@
|
|
New = @'
|
|
_ => CultNetMessage::Error { error: String::new() },
|
|
'@
|
|
}
|
|
@{
|
|
Id = 'D16L'
|
|
Rule = 'The answer names both messages the service accepts, so a client that guessed wrong learns what to send.'
|
|
Test = 'serve::tests::a_malformed_envelope_is_answered_with_a_failure_and_touches_no_mind'
|
|
File = 'crates/huginn-daemon/src/serve.rs'
|
|
Old = @'
|
|
_ => CultNetMessage::Error {
|
|
error: format!(
|
|
"{MIND_SERVICE_ID} answers cultnet.operation_request.v0 and cultnet.schema_catalog_request.v0"
|
|
),
|
|
},
|
|
'@
|
|
New = @'
|
|
_ => CultNetMessage::Error { error: format!("{MIND_SERVICE_ID} answers cultnet.operation_request.v0") },
|
|
'@
|
|
}
|
|
)
|
|
}
|