Upgrade workspace to edition 2024, add --local flag to agent run

Edition 2024 changes:
- gen is reserved: rename variable in query/engine.rs
- set_var is unsafe: wrap in unsafe block in cli/agent.rs
- match ergonomics: add explicit & in spectral.rs filter closure

New --local flag for `poc-memory agent run` bypasses the daemon and
runs the agent directly in-process. Useful for testing agent prompt
changes without waiting in the daemon queue.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Kent Overstreet 2026-03-18 22:44:36 -04:00
parent c153daacd5
commit 0a62832fe3
7 changed files with 1515 additions and 56 deletions

View file

@ -21,6 +21,8 @@ peg = "0.8"
paste = "1"
jobkit = { git = "https://evilpiepirate.org/git/jobkit.git/" }
jobkit-daemon = { git = "https://evilpiepirate.org/git/jobkit-daemon.git/" }
reqwest = { version = "0.12", features = ["blocking", "json"] }
poc-agent = { path = "../poc-agent" }
redb = "2"
log = "0.4"
ratatui = "0.29"

View file

@ -3,9 +3,10 @@
use crate::store;
use crate::agents::llm;
pub fn cmd_run_agent(agent: &str, count: usize, target: &[String], query: Option<&str>, dry_run: bool, debug: bool) -> Result<(), String> {
pub fn cmd_run_agent(agent: &str, count: usize, target: &[String], query: Option<&str>, dry_run: bool, debug: bool, local: bool) -> Result<(), String> {
if dry_run {
std::env::set_var("POC_MEMORY_DRY_RUN", "1");
// SAFETY: single-threaded at this point (CLI startup, before any agent work)
unsafe { std::env::set_var("POC_MEMORY_DRY_RUN", "1"); }
}
let mut store = store::Store::load()?;
let log = |msg: &str| eprintln!("[{}] {}", agent, msg);
@ -28,26 +29,29 @@ pub fn cmd_run_agent(agent: &str, count: usize, target: &[String], query: Option
};
if !resolved_targets.is_empty() {
// Queue one daemon task per target node
// --local or daemon unavailable: run directly
if local || crate::agents::daemon::send_rpc_pub("ping").is_none() {
if !local {
eprintln!("Daemon not running — falling back to local execution");
}
for (i, key) in resolved_targets.iter().enumerate() {
eprintln!("[{}] [{}/{}] {}", agent, i + 1, resolved_targets.len(), key);
if i > 0 { store = store::Store::load()?; }
if let Err(e) = crate::agents::knowledge::run_one_agent_with_keys(
&mut store, agent, &[key.clone()], count, "test", &log, debug,
) {
eprintln!("[{}] ERROR on {}: {}", agent, key, e);
}
}
return Ok(());
}
// Queue to daemon
let mut queued = 0;
for key in &resolved_targets {
let cmd = format!("run-agent {} 1 target:{}", agent, key);
match crate::agents::daemon::send_rpc_pub(&cmd) {
Some(_) => queued += 1,
None => {
eprintln!("Daemon not running — falling back to local execution");
// Local fallback: run sequentially
for (i, key) in resolved_targets.iter().enumerate() {
eprintln!("[{}] [{}/{}] {}", agent, i + 1, resolved_targets.len(), key);
if i > 0 { store = store::Store::load()?; }
if let Err(e) = crate::agents::knowledge::run_one_agent_with_keys(
&mut store, agent, &[key.clone()], count, "test", &log, debug,
) {
eprintln!("[{}] ERROR on {}: {}", agent, key, e);
}
}
return Ok(());
}
if crate::agents::daemon::send_rpc_pub(&cmd).is_some() {
queued += 1;
}
}
eprintln!("[{}] queued {} tasks to daemon", agent, queued);

View file

@ -587,6 +587,9 @@ enum AgentCmd {
/// Debug — print full prompt and response
#[arg(long)]
debug: bool,
/// Run locally instead of queuing to daemon
#[arg(long)]
local: bool,
},
/// Show spaced repetition replay queue
#[command(name = "replay-queue")]
@ -832,8 +835,8 @@ fn main() {
AgentCmd::FactMine { path, batch, dry_run, output, min_messages }
=> cli::agent::cmd_fact_mine(&path, batch, dry_run, output.as_deref(), min_messages),
AgentCmd::FactMineStore { path } => cli::agent::cmd_fact_mine_store(&path),
AgentCmd::Run { agent, count, target, query, dry_run, debug }
=> cli::agent::cmd_run_agent(&agent, count, &target, query.as_deref(), dry_run, debug),
AgentCmd::Run { agent, count, target, query, dry_run, debug, local }
=> cli::agent::cmd_run_agent(&agent, count, &target, query.as_deref(), dry_run, debug, local),
AgentCmd::ReplayQueue { count } => cli::agent::cmd_replay_queue(count),
AgentCmd::Evaluate { matchups, model, dry_run }
=> cli::agent::cmd_evaluate_agents(matchups, &model, dry_run),

View file

@ -434,7 +434,7 @@ pub fn run_query(
}
current = match stage {
Stage::Generator(gen) => run_generator(gen, store),
Stage::Generator(g) => run_generator(g, store),
Stage::Filter(filt) => {
current.into_iter()
@ -470,8 +470,8 @@ pub fn run_query(
current
}
fn run_generator(gen: &Generator, store: &Store) -> Vec<(String, f64)> {
match gen {
fn run_generator(g: &Generator, store: &Store) -> Vec<(String, f64)> {
match g {
Generator::All => {
store.nodes.iter()
.filter(|(_, n)| !n.deleted)

View file

@ -474,7 +474,7 @@ pub fn analyze_positions(
let coords = &emb.coords[&key];
let (nearest_community, dist_to_nearest) = centers.iter()
.filter(|(&c, _)| c != comm)
.filter(|&(&c, _)| c != comm)
.map(|(&c, center)| (c, weighted_distance(coords, center, &weights)))
.min_by(|a, b| a.1.total_cmp(&b.1))
.unwrap_or((comm, f64::MAX));