Skip to main content

CloudClient

Struct CloudClient 

Source
pub struct CloudClient { /* private fields */ }

Implementations§

Source§

impl CloudClient

Source

pub fn new() -> Self

Source

pub async fn create() -> Self

Source

pub fn resolve_cloud_url() -> String

Source

pub async fn auth_pool() -> Result<SqlitePool, String>

Source

pub async fn auth_pool_public() -> Result<SqlitePool, String>

Source

pub async fn save_token(token: &str) -> Result<(), String>

Source

pub async fn save_refresh_token(refresh_token: &str) -> Result<(), String>

Source

pub async fn save_login_tokens( token: &str, refresh_token: Option<&str>, ) -> Result<(), String>

Source

pub async fn load_token() -> Option<String>

Source

pub async fn load_token_quiet() -> Option<String>

Like [load_token] but never writes a decrypt-failure warning to stderr. Use from read-only diagnostics / render loops (e.g. the embedder status probe) where a corrupt token must not spam the terminal.

Source

pub async fn load_refresh_token() -> Option<String>

Source

pub async fn clear_token() -> Result<(), String>

Source

pub async fn refresh_saved_token() -> Option<String>

Source

pub const fn is_logged_in(&self) -> bool

Source

pub fn base_url(&self) -> &str

Source

pub async fn recall_past_verdicts( &self, req: RecallPastVerdictsRequest, ) -> Result<Vec<PastVerdict>, CoreError>

Call the cloud review-memory endpoint for semantically similar past verdicts.

This call is deliberately fault-tolerant:

  • On HTTP 403 (e.g. team-scope recall without the team entitlement, or a capacity/permission limit) — returns Ok(vec![]) so users proceed with a normal review. Personal review-memory recall is available on Cloud Free; paid plans expand capacity and team scope.
  • On network / decode errors — logs and returns Ok(vec![]); a failing recall must NEVER block a review.

The endpoint is hand-wired with reqwest rather than routed through openapi_contract::api! because the request/response types carry extra fields and derive traits beyond what the generated code provides.

Source

pub async fn record_review_metrics( &self, review_id: &str, req: RecordReviewMetricsRequest, ) -> bool

POST /reviews/{id}/metrics.

Uploads token usage + estimated cost + wall-clock duration for a single review run. All fields on the request are optional; pass None for anything the engine doesn’t have and the server leaves that column alone.

This is fire-and-forget — a failed metrics upload must NEVER block a review. Returns true on 2xx so unit tests can assert the happy path, but every production caller should ignore the bool.

Source

pub async fn save_trajectory(&self, pr_review_id: &str, steps: Value) -> bool

POST /reviews/{prReviewId}/trajectory.

Takes the serialized output of TrajectoryBuilder::into_json() and hands it to the cloud side, which parses it with a Zod discriminated union that mirrors the Rust enum in review_trajectory.rs exactly. Fire-and-forget — a missing trajectory is never a review blocker.

Source

pub async fn get_trajectory( &self, pr_review_id: &str, ) -> Result<GetTrajectoryResponse, String>

GET /reviews/{prReviewId}/trajectory for the difflore trajectory <review-id> CLI renderer.

Sibling of [save_trajectory]: it fetches the recorded decision trail for one review and decodes it back into the canonical crate::review_trajectory::TrajectoryStep enum. Unlike the recall path this is not fail-safe-to-empty — the caller (an explicit, user-invoked trajectory command) wants to know why a fetch failed (not logged in, plan-gated, review not found, network down) so it can print an actionable message. We therefore surface the underlying error string from [get_json] verbatim:

  • "not_logged_in" when no cloud token is present, and
  • "[get_trajectory] returned 4xx: …" for plan-limit / not-found / other HTTP failures.

The cloud returns a zero-UUID placeholder with steps: [] (not a 404) when a review exists but has no persisted trajectory, so an Ok with an empty steps vec is the “nothing recorded yet” signal the renderer handles gracefully.

Source

pub async fn track_mcp_query( &self, file: &str, intent: Option<&str>, rules_injected: usize, strict_match_count: usize, rule_titles: Vec<String>, rule_ids: Vec<String>, client_label: Option<&str>, repo_full_name: Option<&str>, ) -> bool

POST /dashboard/mcp-query — live agent-activity telemetry.

Called every time the MCP server answers a canonical rule-search tool invocation. The cloud side appends a row to metric_events and the dashboard’s “Recent agent activity” card polls for new entries. Fire- and-forget — a missing telemetry hit must never block the MCP response (agents time out on slow MCP tools).

Kept flat to avoid churn in the outbox payload schema and callers.

Source

pub async fn record_accepted_edit(&self, req: RecordAcceptedEditRequest) -> bool

POST /accepted-edits.

Called when the user locally accepts an edit (IDE / CLI). The cloud side inserts a fix_acceptances row which the rule-promoter worker later aggregates into candidate rules. Fire-and-forget: a failed acceptance POST must never block the local accept UX.

Source

pub async fn record_accepted_edit_response( &self, req: RecordAcceptedEditRequest, ) -> Result<RecordAcceptedEditResponse, String>

POST /accepted-edits and return the cloud attribution details.

The response tells the CLI whether the raw accepted edit was also linked to a team-scoped fix_outcome observation. That distinction matters for Impact evidence: raw accepted rows prove usage, but rule-linked observations prove the live fix path reused review memory.

Source

pub async fn upload_imported_reviews( &self, req: &UploadImportedReviewsRequest, ) -> bool

POST /reviews/import — GitHub PR History Import.

Uploads locally-imported PR review comments to the cloud for team-wide recall and analytics. Fire-and-forget — a failed upload must never block the local import pipeline.

Source

pub async fn post_observations(&self, batch: &[Observation]) -> bool

Source

pub async fn post_observation_events(&self, batch: &[ObservationEvent]) -> bool

Source

pub async fn post_observation_events_result( &self, batch: &[ObservationEvent], ) -> Result<(), String>

Source

pub async fn build_corpus( &self, req: &BuildCorpusRequest, ) -> Result<BuildCorpusResult, String>

POST /knowledge/corpus — build a filtered snapshot of rules + extractions into a new corpus. Cloud spec §3.16.

Source

pub async fn prime_corpus( &self, corpus_id: &str, ) -> Result<PrimeCorpusResult, String>

POST /knowledge/corpus/{id}/prime — allocate a session token and mark the corpus primed. Returns the session token + ISO ts.

Source

pub async fn query_corpus( &self, corpus_id: &str, question: &str, ) -> Result<QueryCorpusResult, String>

POST /knowledge/corpus/{id}/query — ask the corpus a question. Returns answer + citations. Errors LlmNotConfigured if the caller has no llmApiKey configured cloud-side (BYOK gate).

Source

pub async fn list_corpora(&self) -> Result<Vec<CorpusSummary>, String>

GET /knowledge/corpora — list this team’s corpora with item counts and prime/query timestamps.

Source

pub async fn get_impact_banner(&self) -> Result<ImpactBannerDto, String>

GET /impact/banner — past verdicts recalled into reviews this week.

Source

pub async fn get_impact_weekly(&self) -> Result<ImpactWeeklyDto, String>

GET /impact/weekly — last 12 weeks of rules / verdicts / fixes.

Source

pub async fn get_impact_top_rules(&self) -> Result<ImpactTopRulesDto, String>

GET /impact/top-rules — top 5 candidate rules across user’s teams.

Source

pub async fn get_impact_coverage(&self) -> Result<ImpactCoverageDto, String>

GET /impact/coverage — repos / PRs / files covered by extractions.

Source

pub async fn get_impact_fix_scorecard( &self, ) -> Result<ImpactFixScorecardDto, String>

GET /impact/fix-scorecard — last 30d fix acceptance rate + trend.

Trait Implementations§

Source§

impl ApiClient for CloudClient

Source§

fn request( &self, method: Method, path: &str, query: Option<&str>, body: Option<String>, ) -> impl Future<Output = Result<Response, ApiError>> + Send

Source§

fn request_stream( &self, method: Method, path: &str, query: Option<&str>, ) -> impl Future<Output = Result<SseStream, ApiError>> + Send

Source§

impl Clone for CloudClient

Source§

fn clone(&self) -> CloudClient

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Default for CloudClient

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl PastVerdictRecaller for CloudClient

Source§

fn recall<'life0, 'async_trait>( &'life0 self, req: RecallPastVerdictsRequest, ) -> Pin<Box<dyn Future<Output = Result<Vec<PastVerdict>, CoreError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> Downcast for T
where T: Any,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert 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>

Convert 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)

Convert &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)

Convert &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
where T: Any + Send + Sync,

Source§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Send + Sync>

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more