Skip to main content

RuleSet

Struct RuleSet 

Source
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

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn weight(&self, rule: &str) -> f32

Read effective weight for a rule. Missing entries return 1.0.

Source

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.

Source

pub fn from_toml_file(path: &Path) -> Result<Self>

Load a RuleSet from a TOML file on disk.

§Errors

I/O or parse errors.

Source

pub fn to_toml_string(&self) -> Result<String, Error>

Render this ruleset as a TOML document. Used by the controller to write a tuned ruleset back to disk before signalling reload.

§Errors

Serialization errors from toml::to_string_pretty.

Trait Implementations§

Source§

impl Clone for RuleSet

Source§

fn clone(&self) -> RuleSet

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for RuleSet

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for RuleSet

Source§

fn default() -> RuleSet

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for RuleSet

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Serialize for RuleSet

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,