agents: deduplicate timestamps, plan expansion, rename agent

- Add compact_timestamp() to store — replaces 5 copies of
  format_datetime(now_epoch()).replace([':', '-', 'T'], "")
  Also fixes missing seconds (format_datetime only had HH:MM).

- Add ConsolidationPlan::to_agent_runs() — replaces identical
  plan-to-runs-list expansion in consolidate.rs and daemon.rs.

- Port job_rename_agent to use run_one_agent — eliminates manual
  prompt building, LLM call, report storage, and visit recording
  that duplicated the shared pipeline.

- Rename Confidence::weight()/value() to delta_weight()/gate_value()
  to clarify the distinction (delta metrics vs depth gating).
This commit is contained in:
ProofOfConcept 2026-03-10 17:48:00 -04:00
parent fe7f636ad3
commit abab85d249
6 changed files with 49 additions and 82 deletions

View file

@ -59,7 +59,8 @@ pub enum Confidence {
}
impl Confidence {
fn weight(self) -> f64 {
/// Weight for delta metrics — how much this action contributes to change measurement.
fn delta_weight(self) -> f64 {
match self {
Self::High => 1.0,
Self::Medium => 0.6,
@ -67,7 +68,8 @@ impl Confidence {
}
}
fn value(self) -> f64 {
/// Confidence value for depth gating — capped below 1.0 so even "high" must clear thresholds.
fn gate_value(self) -> f64 {
match self {
Self::High => 0.9,
Self::Medium => 0.6,
@ -111,7 +113,7 @@ pub fn parse_write_nodes(text: &str) -> Vec<Action> {
content = covers_re.replace(&content, "").trim().to_string();
Action {
weight: confidence.weight(),
weight: confidence.delta_weight(),
kind: ActionKind::WriteNode { key, content, covers },
confidence,
depth: 0,
@ -347,8 +349,7 @@ pub fn run_one_agent(
let output = llm::call_sonnet(llm_tag, &agent_batch.prompt)?;
// Store raw output for audit trail
let ts = store::format_datetime(store::now_epoch())
.replace([':', '-', 'T'], "");
let ts = store::compact_timestamp();
let report_key = format!("_{}-{}-{}", llm_tag, agent_name, ts);
let provenance = agent_provenance(agent_name);
store.upsert_provenance(&report_key, &output, provenance).ok();
@ -602,7 +603,7 @@ fn run_cycle(
config: &KnowledgeLoopConfig,
depth_db: &mut DepthDb,
) -> Result<CycleResult, String> {
let timestamp = chrono::Local::now().format("%Y%m%dT%H%M%S").to_string();
let timestamp = store::compact_timestamp();
eprintln!("\n{}", "=".repeat(60));
eprintln!("CYCLE {}{}", cycle_num, timestamp);
eprintln!("{}", "=".repeat(60));
@ -644,7 +645,7 @@ fn run_cycle(
match &action.kind {
ActionKind::WriteNode { key, covers, .. } => {
let conf_val = action.confidence.value();
let conf_val = action.confidence.gate_value();
let req = required_confidence(depth, config.confidence_base);
let source_uses: Vec<u32> = covers.iter()