(&self)
| 73 | |
| 74 | impl 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 = |
| 86 | work_start_session(self.session_id.as_deref(), |name| { |
| 87 | match std::env::var(name) { |
| 88 | Ok(value) => Ok(Some(value)), |
| 89 | Err(std::env::VarError::NotPresent) => Ok(None), |
| 90 | Err(std::env::VarError::NotUnicode(_)) => Err(CliError::InvalidArgument { |
| 91 | message: format!("{name} must contain a valid session context string"), |
| 92 | }), |
| 93 | } |
| 94 | })?; |
| 95 | let Some(session_id) = session_id else { |
| 96 | if self.turn.is_some() { |
| 97 | return Err(CliError::InvalidArgument { |
| 98 | message: "--turn requires --session-id or ATOMIC_SESSION_ID".into(), |
| 99 | }); |
| 100 | } |
| 101 | return Ok(()); // Human status-only updates remain supported. |
| 102 | }; |
| 103 | let root = find_repository_root()?; |
| 104 | let uid = { |
| 105 | let repo = |
| 106 | crate::commands::open_readonly_repository(&root).map_err(CliError::Repository)?; |
| 107 | let inputs = |
| 108 | super::bridge::read_intent(&repo, &self.id).map_err(CliError::Repository)?; |
| 109 | inputs |
| 110 | .frontmatter |
| 111 | .get("uid") |
| 112 | .and_then(|value| value.as_str()) |
| 113 | .filter(|uid| !uid.is_empty()) |
| 114 | .ok_or_else(|| CliError::InvalidArgument { |
| 115 | message: "intent has no canonical UID; cannot bind work start".into(), |
| 116 | })? |
| 117 | .to_string() |
| 118 | }; |
| 119 | let dot = Repository::canonical_dot_dir(&root).map_err(CliError::Repository)?; |
| 120 | let store = atomic_agent::turn::session::SessionStore::new(dot.join("sessions")) |
| 121 | .map_err(|error| CliError::Internal(error.into()))?; |
| 122 | // Persist the declaration before status mutation or any record hook. |
| 123 | let binding = store |
| 124 | .bind_turn_intent(&session_id, self.turn, &uid) |
| 125 | .map_err(|error| CliError::Internal(error.into()))?; |
| 126 | println!( |
| 127 | "Bound governing intent: {} (session {}, turn {})", |
| 128 | binding.intent_uid, binding.session_id, binding.turn_number |
| 129 | ); |
| 130 | Ok(()) |
| 131 | } |
| 132 |
no test coverage detected