[core] Canon, claims, hooks: strict parser, fail-closed claim checker, hook templates

This commit is contained in:
2026-11-23 01:35:27 +01:00
parent db21efcddf
commit 5b6cc34b6f
8 changed files with 1567 additions and 151 deletions
+29 -7
View File
@@ -87,11 +87,27 @@ fn value() -> impl Strategy<Value = String> {
fn gen_file() -> impl Strategy<Value = (String, Vec<GenFact>, [String; 5], Status)> {
let id = "[a-z0-9]([a-z0-9-]{0,30}[a-z0-9])?";
let facts = prop::collection::btree_map(1u32..=9999, (fact_text(), any::<bool>()), 0..40).prop_map(|m| {
m.into_iter().map(|(id, (text, assumption))| GenFact { id, text, assumption }).collect::<Vec<_>>()
});
let status = prop_oneof![Just(Status::Released), Just(Status::Beta), Just(Status::Planned)];
(id, facts, [value(), value(), value(), value(), value()], status)
let facts = prop::collection::btree_map(1u32..=9999, (fact_text(), any::<bool>()), 0..40)
.prop_map(|m| {
m.into_iter()
.map(|(id, (text, assumption))| GenFact {
id,
text,
assumption,
})
.collect::<Vec<_>>()
});
let status = prop_oneof![
Just(Status::Released),
Just(Status::Beta),
Just(Status::Planned)
];
(
id,
facts,
[value(), value(), value(), value(), value()],
status,
)
}
fn render(id: &str, facts: &[GenFact], v: &[String; 5], status: Status, shuffle: u64) -> String {
@@ -114,7 +130,12 @@ fn render(id: &str, facts: &[GenFact], v: &[String; 5], status: Status, shuffle:
if i % 7 == 3 {
s.push_str("\n## More\n\nSome prose.\n");
}
s.push_str(&format!("- [F{}] {}{}\n", f.id, f.text, if f.assumption { " (assumption)" } else { "" }));
s.push_str(&format!(
"- [F{}] {}{}\n",
f.id,
f.text,
if f.assumption { " (assumption)" } else { "" }
));
}
s
}
@@ -140,7 +161,8 @@ proptest! {
hooks::SLOTS.iter().map(|s| (s.to_string(), "{app}".to_string())).collect();
for h in hs {
let filled = h.fill(&v).unwrap();
prop_assert!(!filled.contains("{feature}"));
let slot = format!("{{{}}}", "feature");
prop_assert!(!filled.contains(&slot));
}
}
}