Skip to main content

forge_engine/runtime/
novelty.rs

1use std::collections::BTreeSet;
2
3use crate::runtime::patch::types::*;
4
5pub type StrategyTag = stabilizer_core::StrategyTag;
6pub use stabilizer_core::AttemptPhase;
7
8#[derive(Debug, Clone)]
9pub struct DeltaPolicy(stabilizer_core::DeltaPolicy);
10
11/// Extract strategy tags from a StructuredPatch's topology.
12pub fn extract_strategy_tags(patch: &StructuredPatch) -> Vec<StrategyTag> {
13    stabilizer_core::extract_strategy_tags(patch)
14}
15
16/// Compute novelty score from strategy tags vs. recent traces.
17pub fn compute_tag_novelty(current_tags: &[String], recent_tags_union: &BTreeSet<String>) -> f64 {
18    stabilizer_core::compute_tag_novelty(current_tags, recent_tags_union)
19}
20
21impl DeltaPolicy {
22    pub fn from_config(config: &crate::config::NoveltyConfig) -> Self {
23        Self(stabilizer_core::DeltaPolicy::new(
24            config.delta_amp_default,
25            config.delta_amp_stabilize1,
26            config.delta_amp_stabilize2,
27            config.delta_amp_clamp,
28        ))
29    }
30
31    pub fn amplitude_for_phase(&self, phase: AttemptPhase) -> f64 {
32        self.0.amplitude_for_phase(phase)
33    }
34}
35
36/// Determine approach family from strategy tags (for MAP-Elites cell key).
37pub fn determine_approach_family(tags: &[String]) -> &'static str {
38    stabilizer_core::determine_approach_family(tags)
39}