cortex/frontend/params.rs
1//! Various parameter data structures for the Rocket frontend routes
2use crate::models::RunMetadata;
3use serde::{Deserialize, Serialize};
4use std::collections::HashMap;
5
6/// Largest report **page size** any report path (human screen or agent endpoint) will honour. The
7/// deepest report rung is a per-task entry list, so an unbounded `page_size` would `LIMIT` the
8/// whole list into one response/render (the unbounded-load class, principle #6); clamp it
9/// everywhere.
10pub const MAX_REPORT_PAGE_SIZE: i64 = 1000;
11
12/// Largest report **offset** any report path will honour. `OFFSET` is scan-and-discard, so a deep
13/// offset is a multi-second query that pins a connection (KNOWN_ISSUES P-4); cap the paginate
14/// depth. The reports are an inspection surface (look at affected papers) — bulk action uses rerun,
15/// which filters server-side without enumerating.
16pub const MAX_REPORT_OFFSET: i64 = 100_000;
17
18#[derive(FromForm)]
19/// Configuration parameters for a frontend reports page
20pub struct ReportParams {
21 /// show all tasks, or only those of the current severity
22 pub all: Option<bool>,
23 /// offset for paging in SQL
24 pub offset: Option<i64>,
25 /// page size for paging in SQL
26 pub page_size: Option<i64>,
27}
28
29/// The JSON body of a human rerun request. Auth is the signed-in [`crate::frontend::actor::
30/// AdminSession`] cookie now — no token in the body — so only the free-text purpose remains.
31#[derive(Serialize, Deserialize)]
32pub struct RerunRequestParams {
33 /// a plain text description for the purpose of the rerun
34 pub description: String,
35}
36
37/// A backend-retrieved report used for filling in Tera-templated pages
38#[derive(Serialize, Default)]
39pub struct TemplateContext {
40 /// global data, as per Rocket examples
41 pub global: HashMap<String, String>,
42 /// tabular data for reporting on corpora
43 pub corpora: Option<Vec<HashMap<String, String>>>,
44 /// tabular data for reporting on services
45 pub services: Option<Vec<HashMap<String, String>>>,
46 /// all registered services (the corpus screen's "activate a service" picker)
47 pub all_services: Option<Vec<HashMap<String, String>>>,
48 /// tabular data for reporting on entries
49 pub entries: Option<Vec<HashMap<String, String>>>,
50 /// tabular data for reporting on message `categories`
51 pub categories: Option<Vec<HashMap<String, String>>>,
52 /// tabular data for reporting on message `whats`
53 pub whats: Option<Vec<HashMap<String, String>>>,
54 /// tabular data for reporting on workers
55 pub workers: Option<Vec<HashMap<String, String>>>,
56 /// tabular data for reporting on rerun history
57 pub history: Option<Vec<RunMetadata>>,
58 /// serialized data for easy plotting of rerun history
59 pub history_serialized: Option<String>,
60 /// Whether the current viewer is a signed-in admin. Gates admin-only affordances in the shared
61 /// templates (e.g. the corpus screen's "Corpus actions"); defaults to `false` (anonymous), so a
62 /// page that doesn't set it shows nothing privileged.
63 pub is_admin: bool,
64}