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

Method turn_intent_binding

atomic-agent/src/turn/session.rs:888–916  ·  view source on GitHub ↗

Read only this turn's declaration; never inherit governance from an earlier turn or infer it from files. Corrupt declarations fail closed.

(
        &self,
        session_id: &str,
        turn_number: u32,
    )

Source from the content-addressed store, hash-verified

886 /// Read only this turn's declaration; never inherit governance from an
887 /// earlier turn or infer it from files. Corrupt declarations fail closed.
888 pub fn turn_intent_binding(
889 &self,
890 session_id: &str,
891 turn_number: u32,
892 ) -> AgentResult<Option<TurnIntentBinding>> {
893 validate_session_id(session_id)?;
894 let path = self
895 .sessions_dir
896 .join(session_id)
897 .join(format!("intent-{turn_number}.json"));
898 let bytes = match std::fs::read(path) {
899 Ok(bytes) => bytes,
900 Err(error) if error.kind() == std::io::ErrorKind::NotFound => return Ok(None),
901 Err(error) => return Err(error.into()),
902 };
903 let failure = |reason: String| AgentError::SessionLoadFailed {
904 session_id: session_id.to_string(),
905 reason,
906 };
907 let binding: TurnIntentBinding =
908 serde_json::from_slice(&bytes).map_err(|error| failure(error.to_string()))?;
909 if binding.session_id != session_id
910 || binding.turn_number != turn_number
911 || binding.intent_uid.trim().is_empty()
912 {
913 return Err(failure("invalid turn intent binding".into()));
914 }
915 Ok(Some(binding))
916 }
917
918 /// Seal governance before any recording attempt, including one that fails
919 /// before publishing a checkpoint. The caller holds `turn-end.lock`.

Callers 3

bind_turn_intentMethod · 0.80
freeze_turn_intentMethod · 0.80

Calls 5

validate_session_idFunction · 0.85
failureFunction · 0.85
readFunction · 0.50
kindMethod · 0.45
is_emptyMethod · 0.45

Tested by

no test coverage detected