pub struct SessionMinedCandidate {
pub session_id: String,
pub ts_ms: i64,
pub source_repo: String,
pub title: String,
pub body: String,
pub file_patterns: Vec<String>,
pub gate_model: String,
pub gate_verdict: String,
pub content_hash: String,
pub origin: String,
pub requires_human_approval: bool,
}Expand description
Wire format for one session-mined candidate. Serialised verbatim
into cloud_outbox.payload_json under kind = "session_mined_candidate".
Every field except gate_verdict carries a hard local invariant —
see the validate method and the constructor builders below.
source_repo is the load-bearing one: it MUST be derived from the
current git remote / cwd and never empty, otherwise the candidate
has no Project Scope and the cloud has no way to attribute it.
Fields§
§session_id: StringPlatform session id from the hook stdin payload (Claude Code
session_id, Cursor session uuid, …). Empty string is not
accepted — cloud-side dedup keys on this.
ts_ms: i64Unix-ms at the moment the gate produced its verdict.
source_repo: Stringowner/repo for the GitHub remote, or the cwd basename as a
fallback for non-GitHub repos. Never empty; rejected if the
builder can’t determine a repo identity for the current
workspace.
title: StringSingle-line title, ≤ TITLE_MAX_CHARS chars. The gate is
instructed to write this as a behavioural rule (imperative or
declarative); rendering on the cloud side adds prefixes like
“Remember:” so we don’t double them.
body: StringMulti-sentence rule body, ≤ BODY_MAX_CHARS chars. Usually
2-5 sentences plus an optional code snippet.
file_patterns: Vec<String>1-3 file globs, never empty. Cloud-side cascade ordering keys on these (rules whose patterns match the target file surface first), so a candidate with zero patterns can never be served.
gate_model: StringProvider:model identifier for the gate call, e.g.
"claude:haiku". Used for audits + future per-model recall.
gate_verdict: String"KEEP" for a brand-new rule, or "MERGE:<id>" where <id> is
the cloud rule id the gate decided to extend. Cloud applies
the MERGE shape against the named rule’s body; KEEP becomes a
fresh candidate_rules row.
content_hash: String16-char hex sha256 of source_repo|title|body. Stable across
retries so the cloud can dedup duplicate outbox uploads of the
same candidate.
origin: StringOrigin discriminator on the wire, always ORIGIN.
requires_human_approval: boolDraft gate; session-mined candidates require human approval.
Implementations§
Source§impl SessionMinedCandidate
impl SessionMinedCandidate
Sourcepub fn try_new(args: SessionMinedCandidateArgs) -> Result<Self, CandidateError>
pub fn try_new(args: SessionMinedCandidateArgs) -> Result<Self, CandidateError>
Build a new candidate from gate output. Truncates title/body to the documented caps, derives the content hash, and pins the origin and draft flag. Callers must drop invalid candidates.
Sourcepub fn validate(&self) -> Result<(), CandidateError>
pub fn validate(&self) -> Result<(), CandidateError>
Re-validate an existing candidate. Used by the outbox dispatcher before posting so a corrupted row (e.g. tampered payload, wrong-origin row migrated in) never reaches the cloud endpoint.
Trait Implementations§
Source§impl Clone for SessionMinedCandidate
impl Clone for SessionMinedCandidate
Source§fn clone(&self) -> SessionMinedCandidate
fn clone(&self) -> SessionMinedCandidate
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for SessionMinedCandidate
impl Debug for SessionMinedCandidate
Source§impl<'de> Deserialize<'de> for SessionMinedCandidate
impl<'de> Deserialize<'de> for SessionMinedCandidate
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 SessionMinedCandidate
Source§impl PartialEq for SessionMinedCandidate
impl PartialEq for SessionMinedCandidate
Source§fn eq(&self, other: &SessionMinedCandidate) -> bool
fn eq(&self, other: &SessionMinedCandidate) -> bool
self and other values to be equal, and is used by ==.Source§impl Serialize for SessionMinedCandidate
impl Serialize for SessionMinedCandidate
impl StructuralPartialEq for SessionMinedCandidate
Auto Trait Implementations§
impl Freeze for SessionMinedCandidate
impl RefUnwindSafe for SessionMinedCandidate
impl Send for SessionMinedCandidate
impl Sync for SessionMinedCandidate
impl Unpin for SessionMinedCandidate
impl UnsafeUnpin for SessionMinedCandidate
impl UnwindSafe for SessionMinedCandidate
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<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
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.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more