MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / load_lifecycle

Function load_lifecycle

atomic-cli/src/commands/agent/lifecycle.rs:839–863  ·  view source on GitHub ↗
(dir: &Path, run_id: &str)

Source from the content-addressed store, hash-verified

837}
838
839fn load_lifecycle(dir: &Path, run_id: &str) -> CliResult<Option<ManagedLifecycle>> {
840 validate_run_id(run_id)?;
841 let path = lifecycle_path(dir, run_id);
842 if !path.exists() {
843 return Ok(None);
844 }
845 let data = fs::read_to_string(&path).map_err(|e| {
846 CliError::Internal(anyhow!(
847 "failed to read managed lifecycle '{}': {}",
848 path.display(),
849 e
850 ))
851 })?;
852 let mut lifecycle: ManagedLifecycle = serde_json::from_str(&data).map_err(|e| {
853 CliError::Internal(anyhow!(
854 "failed to parse managed lifecycle '{}': {}",
855 path.display(),
856 e
857 ))
858 })?;
859 if lifecycle.refusal.is_none() {
860 lifecycle.refusal = load_first_refusal(dir, run_id)?;
861 }
862 Ok(Some(lifecycle))
863}
864
865fn save_lifecycle(dir: &Path, lifecycle: &ManagedLifecycle) -> CliResult<()> {
866 validate_run_id(&lifecycle.run_id)?;

Callers 3

runMethod · 0.85
persist_refusalFunction · 0.85

Calls 5

validate_run_idFunction · 0.85
lifecycle_pathFunction · 0.85
load_first_refusalFunction · 0.85
is_noneMethod · 0.80
existsMethod · 0.45