-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chore: state poc #37
chore: state poc #37
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -9,6 +9,7 @@ use txtx_core::{ | |||||
manifest::{file::read_runbooks_from_manifest, WorkspaceManifest}, | ||||||
start_unsupervised_runbook_runloop, | ||||||
std::StdAddon, | ||||||
types::RunbookSnapshotContext, | ||||||
}; | ||||||
|
||||||
pub fn get_addon_by_namespace(namespace: &str) -> Option<Box<dyn Addon>> { | ||||||
|
@@ -21,20 +22,24 @@ pub fn get_addon_by_namespace(namespace: &str) -> Option<Box<dyn Addon>> { | |||||
} | ||||||
None | ||||||
} | ||||||
|
||||||
pub const DEFAULT_ENVIRONMENT: &str = "localnet"; | ||||||
pub async fn execute_runbook( | ||||||
runbook_id: String, | ||||||
progress_tx: Sender<BlockEvent>, | ||||||
txtx_manifest_location: FileLocation, | ||||||
) -> Result<(), String> { | ||||||
let manifest = WorkspaceManifest::from_location(&txtx_manifest_location)?; | ||||||
let runbook_selector = vec![runbook_id.to_string()]; | ||||||
let mut runbooks = | ||||||
read_runbooks_from_manifest(&manifest, &Some("localnet".into()), Some(&runbook_selector))?; | ||||||
let mut runbooks = read_runbooks_from_manifest( | ||||||
&manifest, | ||||||
&Some(DEFAULT_ENVIRONMENT.into()), | ||||||
Some(&runbook_selector), | ||||||
)?; | ||||||
let top_level_inputs_map = | ||||||
manifest.get_runbook_inputs(&Some("localnet".into()), &vec![], None)?; | ||||||
manifest.get_runbook_inputs(&Some(DEFAULT_ENVIRONMENT.into()), &vec![], None)?; | ||||||
|
||||||
let Some((mut runbook, runbook_sources, _state, _smt)) = runbooks.swap_remove(&runbook_id) | ||||||
let Some((mut runbook, runbook_sources, _state, runbook_state_location)) = | ||||||
runbooks.swap_remove(&runbook_id) | ||||||
else { | ||||||
return Err(format!("Deployment {} not found", runbook_id)); | ||||||
}; | ||||||
|
@@ -54,6 +59,32 @@ pub async fn execute_runbook( | |||||
|
||||||
runbook.enable_full_execution_mode(); | ||||||
|
||||||
if let Some(state_file_location) = runbook_state_location.clone() { | ||||||
match state_file_location.load_execution_snapshot( | ||||||
true, | ||||||
&runbook.runbook_id.name, | ||||||
&runbook.top_level_inputs_map.current_top_level_input_name(), | ||||||
) { | ||||||
Ok(old_snapshot) => { | ||||||
let ctx = RunbookSnapshotContext::new(); | ||||||
let execution_context_backups = runbook.backup_execution_contexts(); | ||||||
let new = runbook.simulate_and_snapshot_flows(&old_snapshot).await?; | ||||||
let consolidated_changes = ctx.diff(old_snapshot, new); | ||||||
|
||||||
runbook.prepare_flows_for_new_plans( | ||||||
&consolidated_changes.new_plans_to_add, | ||||||
execution_context_backups, | ||||||
); | ||||||
|
||||||
let _ = | ||||||
runbook.prepared_flows_for_updated_plans(&consolidated_changes.plans_to_update); | ||||||
} | ||||||
Err(e) => { | ||||||
println!("{} {}", red!("x"), e); | ||||||
} | ||||||
} | ||||||
} | ||||||
|
||||||
let res = start_unsupervised_runbook_runloop(&mut runbook, &progress_tx).await; | ||||||
if let Err(diags) = res { | ||||||
println!("{} Execution aborted", red!("x")); | ||||||
|
@@ -64,12 +95,7 @@ pub async fn execute_runbook( | |||||
return Ok(()); | ||||||
} | ||||||
|
||||||
if let Err(diags) = res { | ||||||
for diag in diags.iter() { | ||||||
println!("{} {}", red!("x"), diag); | ||||||
} | ||||||
std::process::exit(1); | ||||||
} | ||||||
let _ = runbook.write_runbook_state(runbook_state_location)?; | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Handle the state writing result. The result of writing the runbook state is ignored with - let _ = runbook.write_runbook_state(runbook_state_location)?;
+ runbook.write_runbook_state(runbook_state_location)?; 📝 Committable suggestion
Suggested change
|
||||||
|
||||||
Ok(()) | ||||||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Verification agent
🧩 Analysis chain
Verify external dependencies.
The dependencies are using paths outside the repository (
../../../txtx/
), which could cause issues with reproducible builds. Consider:🏁 Script executed:
Length of output: 245
External Dependencies Missing – Action Required
The verification confirms that both dependency paths (
../../../txtx/crates/txtx-core
and../../../txtx/addons/svm
) do not exist. This outcome directly supports the concern that these external path dependencies could lead to reproducibility issues. It is advisable to either incorporate these dependencies into the repository or publish them to crates.io and use version specifications to avoid future build complications.crates/cli/Cargo.toml
(lines 19-22)