Fill the F6 gap in its owner: a public slug door on Slug
Slug::validate_slug applies the crate's own dotted_text grammar, the same check every Slug field is held to, following PipelineRef::validate_ref's pattern. Named validate_slug rather than validate so it does not shadow Bounded::validate for in-crate callers. Adds a leaf test covering one valid dotted name and refusals for fullwidth characters, .., both path separators, the empty string, and an empty label. Self's ruling on the F6 fork, 2026-09-22: fill the gap in its owner rather than leaving Huginn's PipelineInstance wrapper beside it. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
parent
b4aab3f7c3
commit
9d3a3efd56
2 changed files with 82 additions and 0 deletions
|
|
@ -211,6 +211,21 @@ bounded_text! {
|
|||
Sha256Hex = 64, |field, value| hex(field, value, 64..=64);
|
||||
}
|
||||
|
||||
impl Slug {
|
||||
/// The public door onto the slug grammar, for a caller outside this crate
|
||||
/// that holds a bare `Slug` and no way to reach `Bounded`, which is
|
||||
/// crate-private. On the pattern of `PipelineRef::validate_ref`: it
|
||||
/// delegates so the grammar keeps one owner, and it applies exactly the
|
||||
/// `dotted_text` check that every `Slug` field in this crate is held to,
|
||||
/// so a caller that validates a declared name this way and a document
|
||||
/// field of the same type refuse the same inputs. Named `validate_slug`
|
||||
/// rather than a bare `validate`, because an inherent `validate` would
|
||||
/// shadow `Bounded`'s for every in-crate caller holding a `Slug`.
|
||||
pub fn validate_slug(&self) -> Result<(), PipelineRefusal> {
|
||||
Bounded::validate(self, "slug")
|
||||
}
|
||||
}
|
||||
|
||||
/// A calendar date, `YYYY-MM-DD`.
|
||||
#[derive(Clone, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize, JsonSchema)]
|
||||
#[serde(transparent)]
|
||||
|
|
@ -2441,4 +2456,33 @@ mod tests {
|
|||
);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// The public door onto the slug grammar, for a caller outside this crate
|
||||
/// holding a bare declared name (Huginn's `require_instance` and
|
||||
/// `Mind::open`, before either reaches admission or the filesystem). It
|
||||
/// applies exactly `dotted_text`: one valid dotted name, and refusals for
|
||||
/// fullwidth characters, `..`, both path separators, the empty string,
|
||||
/// and an empty label.
|
||||
#[test]
|
||||
fn slug_validate_applies_the_dotted_grammar() {
|
||||
assert_eq!(slug("huginn-yggdrasil").validate_slug(), Ok(()));
|
||||
assert_eq!(slug("outer.inner").validate_slug(), Ok(()));
|
||||
|
||||
let refused = |value: &str, why: &str| {
|
||||
let result = slug(value).validate_slug();
|
||||
assert!(
|
||||
matches!(&result, Err(PipelineRefusal::InvalidFormat { field, .. }) if field == "slug"),
|
||||
"{why}: {value:?} was not refused, got {result:?}"
|
||||
);
|
||||
};
|
||||
|
||||
refused("\u{FF41}\u{FF41}", "fullwidth characters are not ascii alphanumeric");
|
||||
refused("..", "a bare .. is an empty label either side of the dot");
|
||||
refused("../escaped", "a forward-slash path separator is not a label byte");
|
||||
refused("..\\escaped", "a backslash path separator is not a label byte");
|
||||
refused("outer\\inner", "a lone backslash inside one label is not a label byte, with no empty label to hide behind");
|
||||
refused("", "the empty string has no label");
|
||||
refused("outer..inner", "an empty label between two dots is refused");
|
||||
refused(".", "a single dot is one empty label");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
38
tools/eureka-cut10-epiphany-mutations.psd1
Normal file
38
tools/eureka-cut10-epiphany-mutations.psd1
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
# Eureka Cut 10 mutation suite, the Epiphany half: the public slug door,
|
||||
# `Slug::validate_slug`, filled into its owner by Self's ruling on the F6
|
||||
# fork. Entries only; the harness is tools/eureka-mutations.ps1.
|
||||
#
|
||||
# powershell -File tools/eureka-mutations.ps1 `
|
||||
# -Entries tools/eureka-cut10-epiphany-mutations.psd1 `
|
||||
# -Target epiphany-pipeline/src/lib.rs `
|
||||
# -Test 'cargo test -p epiphany-pipeline --lib'
|
||||
#
|
||||
# G1 is the revert: the door answers `Ok` to everything, which is exactly the
|
||||
# gap Huginn's throwaway `PipelineInstance` wrapper used to paper over. G1L is
|
||||
# a loosening reachable through the same door as the leaf's other text
|
||||
# fields: admitting a lone backslash inside one label. The fixture
|
||||
# `outer\inner` has no empty label for the loosening to hide behind, so it
|
||||
# dies only on the backslash byte itself.
|
||||
@{
|
||||
Mutations = @(
|
||||
@{
|
||||
Id = 'G1'
|
||||
Rule = 'The public slug door applies the crate''s own grammar: a declared name outside the crate is held to the same check every Slug field is (Self''s ruling on the F6 fork).'
|
||||
Test = 'tests::slug_validate_applies_the_dotted_grammar'
|
||||
Old = ' pub fn validate_slug(&self) -> Result<(), PipelineRefusal> {
|
||||
Bounded::validate(self, "slug")
|
||||
}'
|
||||
New = ' pub fn validate_slug(&self) -> Result<(), PipelineRefusal> {
|
||||
let _ = self;
|
||||
Ok(())
|
||||
}'
|
||||
},
|
||||
@{
|
||||
Id = 'G1L'
|
||||
Rule = 'A label byte is exactly `[A-Za-z0-9_-]`: a lone backslash inside one label is refused, not just a backslash beside an empty label.'
|
||||
Test = 'tests::slug_validate_applies_the_dotted_grammar'
|
||||
Old = ' .all(|byte| byte.is_ascii_alphanumeric() || matches!(byte, b''_'' | b''-''));'
|
||||
New = ' .all(|byte| byte.is_ascii_alphanumeric() || matches!(byte, b''_'' | b''-'' | b''\\''));'
|
||||
}
|
||||
)
|
||||
}
|
||||
Reference in a new issue