pub struct RuleSet {
pub enabled: BTreeMap<String, bool>,
pub weights: BTreeMap<String, f32>,
pub version: Option<String>,
}Expand description
Hot-reloadable rule configuration. Carries an enable flag and a
soft weight in [0.0, 1.0] for each of the 8 categorical rules
the encoder knows about. weights is stored for the closed-loop
bandit / experiment generator; the encoder itself treats
weight < ENABLE_WEIGHT_THRESHOLD as “off” and otherwise consults
enabled.
Missing keys default to enabled / weight 1.0, so a sparse TOML file can express only the deltas from the v1 default ruleset.
Fields§
§enabled: BTreeMap<String, bool>Per-rule on/off override. Keys come from RULE_NAMES.
Anything not listed is enabled.
weights: BTreeMap<String, f32>Per-rule weight in [0.0, 1.0]. Used by the bandit; the
encoder uses it only to derive an effective on/off when the
enabled map omits the key.
version: Option<String>Optional version tag, surfaced by the dashboard / statusline so an operator can tell at a glance which ruleset is live.
Implementations§
Source§impl RuleSet
impl RuleSet
Sourcepub fn default_v1() -> Self
pub fn default_v1() -> Self
The v1 default ruleset. Stable inline rules and lossless tool-output cleanup are enabled; canary-only semantic rewrites stay disabled. This remains identical in observable behaviour to the constants-only encoder for prompt text.
success and failure are disabled by default as of
2026-04-24: a per-rule ablation study (commit d431b90,
scripts/ablate_rules.py) showed they fire 11 and 28 times
respectively on the real audit corpus but produce -13 and
-42 tokens of “savings” — the unicode glyph substitutions
(✓, ✗) tokenize to more tokens than the ASCII originals
on the Claude tokenizers. Shipping them enabled actively
harmed compression. Consumers that want the legacy
behaviour can still opt in explicitly, and the
safe_canary_v1 ruleset (introduced earlier for the same
reason) remains available as a typed checkpoint.
Sourcepub fn safe_canary_v1() -> Self
pub fn safe_canary_v1() -> Self
Lower-risk canary ruleset from the autoresearch loop: disable the
success/failure glyph substitutions while keeping lossless tool-output
cleanup enabled. This preserves English polarity words, which reduces
semantic risk on prompts where success/failure are domain terms.
Sourcepub fn agentic_canary_v2() -> Self
pub fn agentic_canary_v2() -> Self
Agentic canary ruleset from the quality-first autoresearch loop. Enables deterministic tool-output codecs that change surface syntax but preserve reconstruction or explicit semantic fields for their supported structures.
Sourcepub fn is_enabled(&self, rule: &str) -> bool
pub fn is_enabled(&self, rule: &str) -> bool
True if the named rule is enabled. Missing entries default
to enabled; a weight below ENABLE_WEIGHT_THRESHOLD also
flips the rule off so a bandit can soft-demote without
explicit toggling.
Sourcepub fn weight(&self, rule: &str) -> f32
pub fn weight(&self, rule: &str) -> f32
Read effective weight for a rule. Missing entries return 1.0.
Sourcepub fn from_toml_str(s: &str) -> Result<Self, Error>
pub fn from_toml_str(s: &str) -> Result<Self, Error>
Parse a TOML document into a RuleSet. Any unrecognised key
is silently dropped (forward compatibility), and any rule
name not in RULE_NAMES is also dropped (defensive against
a corrupted ruleset file).
§Errors
Returns the underlying TOML parse error.
Sourcepub fn from_toml_file(path: &Path) -> Result<Self>
pub fn from_toml_file(path: &Path) -> Result<Self>
Trait Implementations§
Source§impl<'de> Deserialize<'de> for RuleSet
impl<'de> Deserialize<'de> for RuleSet
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Auto Trait Implementations§
impl Freeze for RuleSet
impl RefUnwindSafe for RuleSet
impl Send for RuleSet
impl Sync for RuleSet
impl Unpin for RuleSet
impl UnsafeUnpin for RuleSet
impl UnwindSafe for RuleSet
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more