Residue batch on Cut 10's fourth fix batch: seal path_for, fill N1's gaps, pin the gate's other axis
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>
This commit is contained in:
parent
4f7e3b5edc
commit
65c46aa59d
7 changed files with 255 additions and 7 deletions
|
|
@ -232,6 +232,88 @@ fn require_grammatical_slug(field: &str, declared: &Slug) -> Result<(), MindRefu
|
|||
})
|
||||
})
|
||||
}
|
||||
'@
|
||||
}
|
||||
# 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(),
|
||||
})
|
||||
})
|
||||
}
|
||||
'@
|
||||
}
|
||||
@{
|
||||
|
|
@ -451,6 +533,54 @@ fn require_grammatical_slug(field: &str, declared: &Slug) -> Result<(), MindRefu
|
|||
}
|
||||
_ => 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,
|
||||
},
|
||||
'@
|
||||
}
|
||||
@{
|
||||
|
|
|
|||
Loading…
Reference in a new issue