pub struct Intent {
pub intent_id: IntentId,
pub prompt: String,
pub session_id: SessionId,
pub model: ModelDescriptor,
pub parent_intent: Option<IntentId>,
pub issue_id: Option<IssueId>,
pub created_at: u64,
}Expand description
The persisted intent. Carries the prompt that caused some operations to be produced, the model that interpreted it, and the session that grouped them. Many ops can share one intent; duplicating the prompt on each would be wasteful and break the “two equal ops hash equal” invariant.
Fields§
§intent_id: IntentId§prompt: String§session_id: SessionId§model: ModelDescriptor§parent_intent: Option<IntentId>For refinement chains (“the user said X, then said ‘now also
handle Y’”). None for top-level intents.
issue_id: Option<IssueId>The typed issue this intent realizes (#949), so provenance links
issue ↔ intent ↔ ops ↔ attestation. None for intents not tied to
an issue; omitted from the serialized form (and the id hash) when
None, so pre-existing intents keep their ids byte-for-byte.
created_at: u64Wall-clock seconds since epoch when this intent was first
created. Excluded from intent_id so the dedup property
holds across runs.
Implementations§
Source§impl Intent
impl Intent
Sourcepub fn new(
prompt: impl Into<String>,
session_id: impl Into<SessionId>,
model: ModelDescriptor,
parent_intent: Option<IntentId>,
) -> Self
pub fn new( prompt: impl Into<String>, session_id: impl Into<SessionId>, model: ModelDescriptor, parent_intent: Option<IntentId>, ) -> Self
Build an intent and compute its content-addressed id.
created_at is filled in from the current wall clock; pass
to Intent::with_timestamp if you want to control it
explicitly (e.g. in tests).
Sourcepub fn with_timestamp(
prompt: impl Into<String>,
session_id: impl Into<SessionId>,
model: ModelDescriptor,
parent_intent: Option<IntentId>,
created_at: u64,
) -> Self
pub fn with_timestamp( prompt: impl Into<String>, session_id: impl Into<SessionId>, model: ModelDescriptor, parent_intent: Option<IntentId>, created_at: u64, ) -> Self
Build an intent with a caller-controlled created_at. Used
in tests to keep golden hashes stable; production code uses
Intent::new.
Sourcepub fn with_issue(self, issue_id: IssueId) -> Self
pub fn with_issue(self, issue_id: IssueId) -> Self
Attach the typed issue this intent realizes (#949), recomputing the id: “implement issue X” and the same prompt with no issue are distinct intents. An intent without an issue serializes exactly as before, so pre-existing ids are unchanged.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Intent
impl<'de> Deserialize<'de> for Intent
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
impl Eq for Intent
impl StructuralPartialEq for Intent
Auto Trait Implementations§
impl Freeze for Intent
impl RefUnwindSafe for Intent
impl Send for Intent
impl Sync for Intent
impl Unpin for Intent
impl UnsafeUnpin for Intent
impl UnwindSafe for Intent
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.