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

Method bind_work_start

atomic-cli/src/commands/intent/update.rs:75–125  ·  view source on GitHub ↗
(&self)

Source from the content-addressed store, hash-verified

73
74impl IntentUpdate {
75 fn bind_work_start(&self) -> CliResult<()> {
76 let starting = matches!(self.status.as_deref(), Some("in_progress" | "in-progress"));
77 if !starting {
78 if self.session_id.is_some() || self.turn.is_some() {
79 return Err(CliError::InvalidArgument {
80 message: "--session-id and --turn require --status in_progress".into(),
81 });
82 }
83 return Ok(());
84 }
85 let session_id = self
86 .session_id
87 .clone()
88 .or_else(|| std::env::var("ATOMIC_SESSION_ID").ok());
89 let Some(session_id) = session_id else {
90 if self.turn.is_some() {
91 return Err(CliError::InvalidArgument {
92 message: "--turn requires --session-id or ATOMIC_SESSION_ID".into(),
93 });
94 }
95 return Ok(()); // Human status-only updates remain supported.
96 };
97 let root = find_repository_root()?;
98 let uid = {
99 let repo =
100 crate::commands::open_readonly_repository(&root).map_err(CliError::Repository)?;
101 let inputs =
102 super::bridge::read_intent(&repo, &self.id).map_err(CliError::Repository)?;
103 inputs
104 .frontmatter
105 .get("uid")
106 .and_then(|value| value.as_str())
107 .filter(|uid| !uid.is_empty())
108 .ok_or_else(|| CliError::InvalidArgument {
109 message: "intent has no canonical UID; cannot bind work start".into(),
110 })?
111 .to_string()
112 };
113 let dot = Repository::canonical_dot_dir(&root).map_err(CliError::Repository)?;
114 let store = atomic_agent::turn::session::SessionStore::new(dot.join("sessions"))
115 .map_err(|error| CliError::Internal(error.into()))?;
116 // Persist the declaration before status mutation or any record hook.
117 let binding = store
118 .bind_turn_intent(&session_id, self.turn, &uid)
119 .map_err(|error| CliError::Internal(error.into()))?;
120 println!(
121 "Bound governing intent: {} (session {}, turn {})",
122 binding.intent_uid, binding.session_id, binding.turn_number
123 );
124 Ok(())
125 }
126
127 /// Resolve the body override: inline `--body` or `--body-stdin`.
128 ///

Callers 1

runMethod · 0.80

Calls 9

find_repository_rootFunction · 0.85
open_readonly_repositoryFunction · 0.85
read_intentFunction · 0.85
bind_turn_intentMethod · 0.80
getMethod · 0.65
cloneMethod · 0.45
okMethod · 0.45
as_strMethod · 0.45
is_emptyMethod · 0.45

Tested by

no test coverage detected