Commit c87a1c38
c87a1c38085dMerged
Scott Nixon <[email protected]> ยท 5 months ago ยท 2 files ยท ~2 modified
Description
feat(attractor-pipeline): quality loop control + checkpoint schema_version
attractor-ohy: Per-(node::upstream) entry counters track self-correction loops. On iteration >=2: 1-second cooldown + sentinel injected into context. On iteration > max_fix_iterations: pipeline aborts. Checkpoint gains schema_version:u32, quality_loop_counters, and quality_last_footprint so loop budgets survive resume. Also fixes step_count/total_cost not being restored from checkpoint on resume.
Details
- Commit
- c87a1c38085d
- Parent
- 1c1fdc6d9207
crates/attractor-pipeline/src/checkpoint.rsmodifiedView file
@@ -33,6 +33,17 @@
3333
/// Total cost accrued so far in USD (for enforcing max_budget_usd across resume).3434
#[serde(default)]3535
pub total_cost: f64,36+
/// Schema version for forward-compatibility. Defaults to 0 on old checkpoints.37+
#[serde(default)]38+
pub schema_version: u32,39+
/// Per-(quality-node-ID, upstream-node-ID) re-entry counters.40+
/// Key format: "<node_id>::<upstream_id>". Persisted so loop budgets41+
/// survive checkpoint resume.42+
#[serde(default)]43+
pub quality_loop_counters: HashMap<String, u32>,44+
/// Last failure_footprint seen for each quality node, keyed by node ID.45+
#[serde(default)]46+
pub quality_last_footprint: HashMap<String, String>,3647
}3748
3849
impl PipelineCheckpoint {@@ -52,6 +63,9 @@
5263
session_id: None,5364
step_count: 0,5465
total_cost: 0.0,66+
schema_version: 1,67+
quality_loop_counters: HashMap::new(),68+
quality_last_footprint: HashMap::new(),5569
}5670
}5771
@@ -73,6 +87,9 @@
7387
session_id: None,7488
step_count,7589
total_cost,90+
schema_version: 1,91+
quality_loop_counters: HashMap::new(),92+
quality_last_footprint: HashMap::new(),7693
}7794
}7895
@@ -95,6 +112,36 @@
95112
session_id: Some(session_id),96113
step_count,97114
total_cost,115+
schema_version: 1,116+
quality_loop_counters: HashMap::new(),117+
quality_last_footprint: HashMap::new(),118+
}119+
}120+
121+
/// Create a checkpoint preserving quality loop counters (used by the engine122+
/// when saving mid-loop state).123+
pub fn with_quality_counters(124+
current_node_id: String,125+
completed_nodes: Vec<String>,126+
node_outcomes: HashMap<String, attractor_types::Outcome>,127+
context_snapshot: HashMap<String, serde_json::Value>,128+
step_count: u64,129+
total_cost: f64,130+
quality_loop_counters: HashMap<String, u32>,131+
quality_last_footprint: HashMap<String, String>,132+
) -> Self {133+
Self {134+
current_node_id,135+
completed_nodes,136+
node_outcomes,137+
context_snapshot,138+
timestamp: chrono::Utc::now().to_rfc3339(),139+
session_id: None,140+
step_count,141+
total_cost,142+
schema_version: 1,143+
quality_loop_counters,144+
quality_last_footprint,98145
}99146
}100147
}crates/attractor-pipeline/src/engine.rsmodifiedView file
Loading diffโฆ