pub struct CloudClient { /* private fields */ }Implementations§
Source§impl CloudClient
impl CloudClient
pub fn new() -> Self
pub async fn create() -> Self
pub fn resolve_cloud_url() -> String
pub async fn auth_pool() -> Result<SqlitePool, String>
pub async fn auth_pool_public() -> Result<SqlitePool, String>
pub async fn save_token(token: &str) -> Result<(), String>
pub async fn save_refresh_token(refresh_token: &str) -> Result<(), String>
pub async fn save_login_tokens( token: &str, refresh_token: Option<&str>, ) -> Result<(), String>
pub async fn load_token() -> Option<String>
Sourcepub async fn load_token_quiet() -> Option<String>
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.
pub async fn load_refresh_token() -> Option<String>
pub async fn clear_token() -> Result<(), String>
pub async fn refresh_saved_token() -> Option<String>
pub const fn is_logged_in(&self) -> bool
pub fn base_url(&self) -> &str
Sourcepub async fn recall_past_verdicts(
&self,
req: RecallPastVerdictsRequest,
) -> Result<Vec<PastVerdict>, CoreError>
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.
Sourcepub async fn record_review_metrics(
&self,
review_id: &str,
req: RecordReviewMetricsRequest,
) -> bool
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.
Sourcepub async fn save_trajectory(&self, pr_review_id: &str, steps: Value) -> bool
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.
Sourcepub async fn get_trajectory(
&self,
pr_review_id: &str,
) -> Result<GetTrajectoryResponse, String>
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.
Sourcepub 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
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.
Sourcepub async fn record_accepted_edit(&self, req: RecordAcceptedEditRequest) -> bool
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.
Sourcepub async fn record_accepted_edit_response(
&self,
req: RecordAcceptedEditRequest,
) -> Result<RecordAcceptedEditResponse, String>
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.
Sourcepub async fn upload_imported_reviews(
&self,
req: &UploadImportedReviewsRequest,
) -> bool
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.
pub async fn post_observations(&self, batch: &[Observation]) -> bool
pub async fn post_observation_events(&self, batch: &[ObservationEvent]) -> bool
pub async fn post_observation_events_result( &self, batch: &[ObservationEvent], ) -> Result<(), String>
Sourcepub async fn build_corpus(
&self,
req: &BuildCorpusRequest,
) -> Result<BuildCorpusResult, String>
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.
Sourcepub async fn prime_corpus(
&self,
corpus_id: &str,
) -> Result<PrimeCorpusResult, String>
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.
Sourcepub async fn query_corpus(
&self,
corpus_id: &str,
question: &str,
) -> Result<QueryCorpusResult, String>
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).
Sourcepub async fn list_corpora(&self) -> Result<Vec<CorpusSummary>, String>
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.
GET /impact/banner — past verdicts recalled into reviews this week.
Sourcepub async fn get_impact_weekly(&self) -> Result<ImpactWeeklyDto, String>
pub async fn get_impact_weekly(&self) -> Result<ImpactWeeklyDto, String>
GET /impact/weekly — last 12 weeks of rules / verdicts / fixes.
Sourcepub async fn get_impact_top_rules(&self) -> Result<ImpactTopRulesDto, String>
pub async fn get_impact_top_rules(&self) -> Result<ImpactTopRulesDto, String>
GET /impact/top-rules — top 5 candidate rules across user’s teams.
Sourcepub async fn get_impact_coverage(&self) -> Result<ImpactCoverageDto, String>
pub async fn get_impact_coverage(&self) -> Result<ImpactCoverageDto, String>
GET /impact/coverage — repos / PRs / files covered by extractions.
Sourcepub async fn get_impact_fix_scorecard(
&self,
) -> Result<ImpactFixScorecardDto, String>
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
impl ApiClient for CloudClient
fn request( &self, method: Method, path: &str, query: Option<&str>, body: Option<String>, ) -> impl Future<Output = Result<Response, ApiError>> + Send
fn request_stream( &self, method: Method, path: &str, query: Option<&str>, ) -> impl Future<Output = Result<SseStream, ApiError>> + Send
Source§impl Clone for CloudClient
impl Clone for CloudClient
Source§fn clone(&self) -> CloudClient
fn clone(&self) -> CloudClient
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Default for CloudClient
impl Default for CloudClient
Source§impl PastVerdictRecaller for CloudClient
impl PastVerdictRecaller for CloudClient
Auto Trait Implementations§
impl !RefUnwindSafe for CloudClient
impl !UnwindSafe for CloudClient
impl Freeze for CloudClient
impl Send for CloudClient
impl Sync for CloudClient
impl Unpin for CloudClient
impl UnsafeUnpin for CloudClient
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<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<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