pub enum Predicate {
All,
Intent {
intent_id: IntentId,
},
Session {
session_id: SessionId,
},
AncestorOf {
op_id: OpId,
},
And(Vec<Predicate>),
Or(Vec<Predicate>),
Not(Box<Predicate>),
}Expand description
A saved query over the operation log. Evaluating against an
OpLog returns the matching OperationRecords.
Serialization is hand-rolled (see the impls below) to avoid the
exponential serde-derive monomorphization that recursive enums
trigger when other crates in the workspace also derive Serialize
on rich types.
Variants§
All
Every op in the log. The main branch’s “history” predicate
after migration is AncestorOf { op_id: <head> }, not All
— All is a different query (“show me everything in
existence”, including ops not yet on any branch).
Intent
Ops produced under a given intent (#131).
Session
Ops produced from a given agent session (#131).
Matches if any of the intent’s session matches; today the op
carries intent_id, and the session is a property of the
intent. Resolution is therefore done via the crate::IntentLog
passed to [evaluate_with_intents].
AncestorOf
Causal ancestry of a given op (the op itself + its parents transitively). This is what today’s named branches map to.
And(Vec<Predicate>)
All-of: an op matches iff it matches every sub-predicate.
Or(Vec<Predicate>)
Any-of: an op matches iff it matches at least one sub-predicate.
Not(Box<Predicate>)
Negation. Note this requires a corpus to negate over —
Not(All) is empty, Not(AncestorOf { x }) is “every op
not in x’s history”. Evaluating a top-level Not falls
back to scanning the whole log; nesting it under And lets
the evaluator narrow the scan to the other clauses’ candidate
set first.
Implementations§
Source§impl Predicate
impl Predicate
Sourcepub fn to_value(&self) -> Value
pub fn to_value(&self) -> Value
Convert to a serde_json::Value. The shape mirrors what an
internally-tagged serde derive would have produced
({"predicate": "...", ...}).
Sourcepub fn from_value(v: &Value) -> Result<Self, String>
pub fn from_value(v: &Value) -> Result<Self, String>
Parse from a serde_json::Value. Errors are stringly-typed
because serde::de::Error would require pulling in serde
derive paths we’re explicitly avoiding.
Sourcepub fn to_json_string(&self) -> String
pub fn to_json_string(&self) -> String
Convenience: serde_json::to_string style.
Sourcepub fn from_json_str(s: &str) -> Result<Self, String>
pub fn from_json_str(s: &str) -> Result<Self, String>
Convenience: serde_json::from_str style.
Trait Implementations§
impl Eq for Predicate
impl StructuralPartialEq for Predicate
Auto Trait Implementations§
impl Freeze for Predicate
impl RefUnwindSafe for Predicate
impl Send for Predicate
impl Sync for Predicate
impl Unpin for Predicate
impl UnsafeUnpin for Predicate
impl UnwindSafe for Predicate
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,
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.