Check a declared instance against the slug grammar on the read path
F6: no declared instance Slug was ever checked against Slug's own grammar before reaching Mind::require_instance's byte comparison, so a name outside the grammar read as merely a foreign mind rather than being refused by its own name. Slug's grammar check is a crate-private trait in epiphany_pipeline, reachable only through a real document, so require_grammatical_instance wraps the declared name in a throwaway PipelineInstance and reads the answer back through PipelineDocument::validate, the leaf's own public door; nothing here re-derives the grammar. Daemon::handle asks it on the read path, before Mind::require_instance, for every request that names an instance. Add a_declared_instance_outside_the_grammar_is_refused_by_name_before_the_identity_check, driving a fullwidth Latin small letter y, and mutation entry S3wide, which folds a fullwidth character to plain ASCII before validating and dies against it. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
parent
7611d1bbf1
commit
4ecbf53056
4 changed files with 112 additions and 6 deletions
|
|
@ -143,6 +143,43 @@
|
|||
Old = ' if declared != self.instance() {'
|
||||
New = ' if !declared.0.eq_ignore_ascii_case(&self.instance().0) {'
|
||||
}
|
||||
@{
|
||||
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 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 = @'
|
||||
pub fn require_grammatical_instance(declared: &Slug) -> Result<(), MindRefusal> {
|
||||
let probe = PipelineDocument::Instance(PipelineInstance {
|
||||
instance: declared.clone(),
|
||||
display_name: Short("grammar-probe".into()),
|
||||
created_at: Date("2026-01-01".into()),
|
||||
host: Short("grammar-probe".into()),
|
||||
});
|
||||
probe.validate().map_err(MindRefusal::Document)
|
||||
}
|
||||
'@
|
||||
New = @'
|
||||
pub fn require_grammatical_instance(declared: &Slug) -> Result<(), MindRefusal> {
|
||||
let folded: String = declared
|
||||
.0
|
||||
.chars()
|
||||
.map(|c| match c as u32 {
|
||||
0xFF01..=0xFF5E => char::from_u32(c as u32 - 0xFEE0).unwrap_or(c),
|
||||
_ => c,
|
||||
})
|
||||
.collect();
|
||||
let probe = PipelineDocument::Instance(PipelineInstance {
|
||||
instance: Slug(folded),
|
||||
display_name: Short("grammar-probe".into()),
|
||||
created_at: Date("2026-01-01".into()),
|
||||
host: Short("grammar-probe".into()),
|
||||
});
|
||||
probe.validate().map_err(MindRefusal::Document)
|
||||
}
|
||||
'@
|
||||
}
|
||||
@{
|
||||
Id = 'D2'
|
||||
Rule = 'Rulings 14 and 18 on the wire: the daemon passes the declared instance to the mind as the client sent it.'
|
||||
|
|
|
|||
Loading…
Reference in a new issue