Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions crates/frameshift-orchestrator/src/audit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ pub struct AuditLog {
entries: Vec<Transition>,
}

/// Loads, appends, and queries persona transition audit records.
impl AuditLog {
/// Maximum number of audit entries retained in memory when loading. Entries
/// older than the most recent `MAX_AUDIT_ENTRIES` are dropped so a log grown
Expand Down Expand Up @@ -124,6 +125,7 @@ pub fn now_timestamp() -> String {
}

#[cfg(test)]
/// Verifies audit persistence, retention, and timestamp behavior.
mod tests {
use super::*;
use tempfile::TempDir;
Expand Down
1 change: 1 addition & 0 deletions crates/frameshift-orchestrator/src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -696,6 +696,7 @@ pub(crate) fn tokenize(text: &str) -> Vec<String> {
}

#[cfg(test)]
/// Verifies project-context collection and tokenization behavior.
mod tests {
use super::*;
use std::fs;
Expand Down
4 changes: 4 additions & 0 deletions crates/frameshift-orchestrator/src/controller.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ pub struct SwitchPolicy {
pub min_gap_fraction: f32,
}

/// Maps operator sensitivity into concrete switching thresholds.
impl SwitchPolicy {
/// Construct a SwitchPolicy from a user-facing sensitivity value in [0.0, 1.0].
///
Expand All @@ -71,6 +72,7 @@ impl SwitchPolicy {
}
}

/// Provides balanced switching thresholds as the default policy.
impl Default for SwitchPolicy {
/// Returns the default policy from sensitivity 0.5 (balanced).
fn default() -> Self {
Expand Down Expand Up @@ -117,6 +119,7 @@ pub struct SwitchController {
challenger: Option<String>,
}

/// Controls automate-mode transitions and persona-switch hysteresis.
impl SwitchController {
/// Create a new `SwitchController` in the `Off` state with the given policy.
pub fn new(policy: SwitchPolicy) -> Self {
Expand Down Expand Up @@ -371,6 +374,7 @@ impl SwitchController {
}

#[cfg(test)]
/// Verifies controller state transitions, thresholds, and debounce behavior.
mod tests {
use super::*;
use crate::policy::ScoreComponents;
Expand Down
4 changes: 4 additions & 0 deletions crates/frameshift-orchestrator/src/embed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,7 @@ fn write_private_file(path: &std::path::Path, contents: &[u8]) -> io::Result<()>
pub(crate) struct BagOfWordsEmbedder;

#[cfg(test)]
/// Produces deterministic test embeddings with a bag-of-words model.
impl Embedder for BagOfWordsEmbedder {
/// Embed `text` as a 64-dimensional word-occurrence histogram.
fn embed(&self, text: &str) -> Vec<f32> {
Expand All @@ -270,6 +271,7 @@ impl Embedder for BagOfWordsEmbedder {
}

#[cfg(test)]
/// Verifies embedding similarity and cache behavior.
mod tests {
use super::*;

Expand Down Expand Up @@ -313,6 +315,7 @@ mod tests {
calls: std::sync::atomic::AtomicUsize,
}

/// Constructs and inspects the embedder used to count cache misses.
impl CountingEmbedder {
/// Fresh counter around the bag-of-words mock.
fn new() -> Self {
Expand All @@ -328,6 +331,7 @@ mod tests {
}
}

/// Counts each delegated embedding operation.
impl Embedder for CountingEmbedder {
/// Delegate to the mock, counting the call.
fn embed(&self, text: &str) -> Vec<f32> {
Expand Down
1 change: 1 addition & 0 deletions crates/frameshift-orchestrator/src/intent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,7 @@ pub fn relatedness(a: Intent, b: Intent) -> f32 {
}

#[cfg(test)]
/// Verifies token classification and intent-relatedness scoring.
mod tests {
use super::*;

Expand Down
2 changes: 2 additions & 0 deletions crates/frameshift-orchestrator/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ pub struct Orchestrator {
pub preferences: Preferences,
}

/// Selects and switches personas using the orchestrator's indexed state.
impl Orchestrator {
/// Create a new `Orchestrator` with the given index and default weights/policy/preferences.
pub fn new(index: PersonaIndex) -> Self {
Expand Down Expand Up @@ -87,6 +88,7 @@ impl Orchestrator {
}

#[cfg(test)]
/// Verifies the public orchestration facade.
mod tests {
use super::*;
use std::collections::BTreeSet;
Expand Down
2 changes: 2 additions & 0 deletions crates/frameshift-orchestrator/src/mode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ pub struct ModeState {
pub sensitivity: f32,
}

/// Loads and persists the operator's automate-mode state.
impl ModeState {
/// Load mode state from a JSON file.
///
Expand Down Expand Up @@ -78,6 +79,7 @@ impl ModeState {
}

#[cfg(test)]
/// Verifies mode-state defaults and persistence.
mod tests {
use super::*;
use tempfile::TempDir;
Expand Down
1 change: 1 addition & 0 deletions crates/frameshift-orchestrator/src/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,7 @@ pub fn select_rich_with_embedder(
}

#[cfg(test)]
/// Verifies end-to-end orchestration runs against temporary persona sources.
mod tests {
use super::*;
use std::fs;
Expand Down
1 change: 1 addition & 0 deletions crates/frameshift-source/src/diff.rs
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,7 @@ fn anchor_token_set(anchors: &[CascadeAnchor]) -> HashSet<String> {
}

#[cfg(test)]
/// Verifies semantic persona-source diff generation.
mod tests {
use super::*;
use crate::patterns::PatternSet;
Expand Down
1 change: 1 addition & 0 deletions crates/frameshift-source/src/error.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use std::path::PathBuf;

#[derive(Debug, thiserror::Error)]
/// Reports persona-source loading, parsing, validation, and serialization failures.
pub enum SourceError {
#[error("i/o error at {path}: {source}")]
Io {
Expand Down
1 change: 1 addition & 0 deletions crates/frameshift-source/src/patch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ pub enum AnchorPosition {
Recency,
}

/// Converts anchor positions to their serialized persona-source representation.
impl AnchorPosition {
/// Returns the lowercase string key used as the `position` field in
/// `CascadeAnchor` TOML entries (e.g. `"top"`, `"l2"`, `"recency"`).
Expand Down
5 changes: 5 additions & 0 deletions crates/frameshift-source/src/patterns.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,13 +91,15 @@ const fn default_schema_version() -> u32 {
1
}

/// Constructs pattern collections for persona sources.
impl PatternSet {
/// Constructs an empty `PatternSet` with default schema version.
pub fn new() -> Self {
Self::default()
}
}

/// Provides an empty versioned pattern collection.
impl Default for PatternSet {
/// Constructs an empty `PatternSet` with `schema_version` set to `1`.
fn default() -> Self {
Expand All @@ -112,10 +114,12 @@ impl Default for PatternSet {
}

#[cfg(test)]
/// Verifies pattern collection TOML serialization.
mod tests {
use super::*;

#[test]
/// Round-trips a populated pattern collection through TOML.
fn pattern_set_toml_roundtrip() {
let original = PatternSet {
schema_version: 1,
Expand Down Expand Up @@ -149,6 +153,7 @@ mod tests {
}

#[test]
/// Round-trips an empty pattern collection through TOML.
fn empty_pattern_set_roundtrips() {
let original = PatternSet::default();
let serialized = toml::to_string(&original).unwrap();
Expand Down
2 changes: 2 additions & 0 deletions crates/frameshift-source/src/persona.rs
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,7 @@ pub struct Persona {
pub default_questions: Vec<DefaultQuestion>,
}

/// Constructs persona definitions with safe empty defaults.
impl Persona {
/// Minimal valid persona -- used as a default when scaffolding.
///
Expand Down Expand Up @@ -294,6 +295,7 @@ impl Persona {
}

#[cfg(test)]
/// Verifies persona TOML serialization and schema compatibility.
mod tests {
use super::*;

Expand Down
5 changes: 5 additions & 0 deletions crates/frameshift-source/src/rules.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ pub enum Layer {
L3,
}

/// Constructs behavioral rule collections for persona sources.
impl RuleSet {
/// Construct an empty `RuleSet`. Equivalent to `RuleSet::default()`.
pub fn new() -> Self {
Expand All @@ -54,10 +55,12 @@ impl RuleSet {
}

#[cfg(test)]
/// Verifies rule collection TOML serialization.
mod tests {
use super::*;

#[test]
/// Round-trips a populated rule collection through TOML.
fn ruleset_toml_roundtrip() {
let original = RuleSet {
rules: vec![
Expand Down Expand Up @@ -91,6 +94,7 @@ mod tests {
}

#[test]
/// Round-trips an empty rule collection through TOML.
fn empty_ruleset_roundtrips() {
let original = RuleSet::default();
let serialized = toml::to_string(&original).unwrap();
Expand All @@ -99,6 +103,7 @@ mod tests {
}

#[test]
/// Preserves optional rule reasoning through TOML serialization.
fn rule_with_reasoning_roundtrips() {
let original = RuleSet {
rules: vec![Rule {
Expand Down
6 changes: 6 additions & 0 deletions crates/frameshift-source/src/skills.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,21 @@ pub struct Skill {
pub mandatory: bool,
}

/// Constructs skill collections for persona sources.
impl SkillSet {
/// Constructs an empty skill collection.
pub fn new() -> Self {
Self::default()
}
}

#[cfg(test)]
/// Verifies skill collection TOML serialization.
mod tests {
use super::*;

#[test]
/// Round-trips a populated skill collection through TOML.
fn skillset_toml_roundtrip() {
let original = SkillSet {
skills: vec![
Expand All @@ -54,6 +58,7 @@ mod tests {
}

#[test]
/// Round-trips an empty skill collection through TOML.
fn empty_skillset_roundtrips() {
let original = SkillSet::default();
let serialized = toml::to_string(&original).unwrap();
Expand All @@ -62,6 +67,7 @@ mod tests {
}

#[test]
/// Preserves the mandatory-skill flag through TOML serialization.
fn skill_with_mandatory_roundtrips() {
let original = SkillSet {
skills: vec![Skill {
Expand Down
6 changes: 6 additions & 0 deletions crates/frameshift-source/src/source.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ pub struct LoadOptions {
pub max_patterns: usize,
}

/// Provides bounded defaults for local persona-source loading.
impl Default for LoadOptions {
/// Returns default load options suitable for local development use.
fn default() -> Self {
Expand All @@ -54,6 +55,7 @@ pub struct PersonaSource {
pub patterns: PatternSet,
}

/// Loads, validates, constructs, and writes composite persona sources.
impl PersonaSource {
/// Constructs a new `PersonaSource` with the given persona and empty rules, skills, and patterns.
pub fn new(persona: Persona) -> Self {
Expand Down Expand Up @@ -214,6 +216,7 @@ fn write_toml<T: serde::Serialize>(path: &PathBuf, value: &T) -> Result<(), Sour
}

#[cfg(test)]
/// Verifies persona-source persistence and loading failures.
mod tests {
use super::*;
use crate::patterns::{AntiPattern, PatternSet, StackCategory};
Expand All @@ -222,6 +225,7 @@ mod tests {
use crate::skills::{Skill, SkillSet};
use std::collections::BTreeMap;

/// Builds a populated persona source shared by persistence tests.
fn sample() -> PersonaSource {
let mut anchor = BTreeMap::new();
anchor.insert(
Expand Down Expand Up @@ -285,6 +289,7 @@ mod tests {
}

#[test]
/// Round-trips a persona source directory through disk.
fn write_then_load_roundtrip() {
let tmp = tempfile_dir();
let original = sample();
Expand All @@ -295,6 +300,7 @@ mod tests {
}

#[test]
/// Rejects a source directory without its required persona file.
fn missing_persona_file_errors() {
let tmp = tempfile_dir();
let err = PersonaSource::load_from_dir(&tmp).unwrap_err();
Expand Down
Loading