forked from kent/consciousness
config: global writable AppConfig; learn settings live there
Runtime-mutable settings (F6's threshold knob, the generate-alternates toggle, anything else that comes along) were ending up as mirrored fields on MindState — each new config setting grew MindState::new's signature and added a clone+sync path. Wrong home. MindState is ephemeral session state, not a config projection. Give AppConfig the same treatment the memory Config has: install it into a global RwLock<AppConfig> at startup via load_app, read through config::app() (returns a read guard), mutate through update_app. The config_writer functions now write to disk AND update the cache atomically, so the one-stop-shop call keeps both in sync. Also while in here: - learn.generate_alternates moves from a sentinel file (~/.consciousness/cache/finetune-alternates, "exists = enabled") into the config under the learn section. On first run with this build, if the sentinel file still exists Mind::new flips the config value to true and removes it. Drops alternates_enabled()/set_alternates(). - Default threshold 0.0000001 → 1.0. With the timestamp filter removed the previous value was letting essentially everything through; 1.0 is a sane "nothing gets through unless you actually want it" default. - score_finetune_candidates takes generate_alternates as a parameter instead of reading a global — caller snapshots the config values once at the top of start_finetune_scoring so the async task doesn't need to hold the config read lock across awaits. - MindState.learn_threshold / learn_generate_alternates gone; the SetLearn* command handlers now just delegate to config_writer. Kent noted RwLock<Arc<AppConfig>> (the pattern used by the memory Config global) is pointless here — nobody needs a snapshot-after- release, reads are short — so this uses a plain RwLock<AppConfig> and returns a read guard. Co-Authored-By: Proof of Concept <poc@bcachefs.org>
This commit is contained in:
parent
343e43afab
commit
313f85f34a
5 changed files with 102 additions and 58 deletions
|
|
@ -109,28 +109,24 @@ impl ScreenView for LearnScreen {
|
|||
}
|
||||
}
|
||||
KeyCode::Char('g') => {
|
||||
// Toggle alternate generation and persist
|
||||
let current = crate::subconscious::learn::alternates_enabled();
|
||||
crate::subconscious::learn::set_alternates(!current);
|
||||
let current = crate::config::app().learn.generate_alternates;
|
||||
let _ = self.mind_tx.send(
|
||||
crate::mind::MindCommand::SetLearnGenerateAlternates(!current));
|
||||
}
|
||||
KeyCode::Char('s') => {
|
||||
app.finetune_send_approved();
|
||||
}
|
||||
KeyCode::Char('+') | KeyCode::Char('=') => {
|
||||
// Raise threshold 10× (less sensitive — fewer candidates)
|
||||
if let Some(ms) = &app.mind_state {
|
||||
let new = ms.learn_threshold * 10.0;
|
||||
let _ = self.mind_tx.send(
|
||||
crate::mind::MindCommand::SetLearnThreshold(new));
|
||||
}
|
||||
// Raise threshold 10× (less sensitive — fewer candidates).
|
||||
let new = crate::config::app().learn.threshold * 10.0;
|
||||
let _ = self.mind_tx.send(
|
||||
crate::mind::MindCommand::SetLearnThreshold(new));
|
||||
}
|
||||
KeyCode::Char('-') => {
|
||||
// Lower threshold 10× (more sensitive — more candidates)
|
||||
if let Some(ms) = &app.mind_state {
|
||||
let new = ms.learn_threshold / 10.0;
|
||||
let _ = self.mind_tx.send(
|
||||
crate::mind::MindCommand::SetLearnThreshold(new));
|
||||
}
|
||||
// Lower threshold 10× (more sensitive — more candidates).
|
||||
let new = crate::config::app().learn.threshold / 10.0;
|
||||
let _ = self.mind_tx.send(
|
||||
crate::mind::MindCommand::SetLearnThreshold(new));
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
|
|
@ -144,8 +140,10 @@ impl ScreenView for LearnScreen {
|
|||
}
|
||||
|
||||
// Now render
|
||||
let gen_on = crate::subconscious::learn::alternates_enabled();
|
||||
let threshold = app.mind_state.as_ref().map(|ms| ms.learn_threshold).unwrap_or(0.0);
|
||||
let (threshold, gen_on) = {
|
||||
let app_cfg = crate::config::app();
|
||||
(app_cfg.learn.threshold, app_cfg.learn.generate_alternates)
|
||||
};
|
||||
let block = Block::default()
|
||||
.title_top(Line::from(screen_legend()).left_aligned())
|
||||
.title_top(Line::from(" learn ").right_aligned())
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue