pub(crate) mod buffer;
pub(crate) mod collect;
pub mod gate;
pub(crate) mod secrets;
pub mod signals;
pub mod upload;
pub const FIELDS_PATH: &str = "/privacy/instance-metrics";
pub fn disclosure(
workspace: &str,
web_url: &str,
sharing: &gate::Sharing,
plan_needs_confirmation: bool,
) -> String {
let lead = if sharing.is_on() {
"This instance sends"
} else {
"When switched on, this instance sends"
};
let confirm = if plan_needs_confirmation && !sharing.is_on() {
" Run `lean-ctx cloud metrics confirm` to share."
} else {
""
};
format!(
"Instance metrics. {lead} hourly counts to {workspace} in LeanCTX Cloud. It sends tokens and \
savings, read modes, tool calls by tool name, compression, how often shortened output \
was fetched back in full, protection and policy-block counts by rule, the names of \
known programs and agent host families no enforcing rule covers (git, docker, \
cursor, …), calls to MCP servers no rule covers (the server name only when your \
workspace's policy names it), sessions, agents used, and model \
spend where it is measured. It never \
sends file content, file paths, prompts, model output, secrets or command lines. \
Connecting also sends this machine's name and each project's folder name as default \
labels (`lean-ctx cloud connect --label <name>` sets another machine label). Field \
list: {}{FIELDS_PATH}. Your workspace controls this with the policy rule \"Share engine \
metrics\" (now: {}).{confirm} To stop it for this instance only: \
`lean-ctx config set cloud.metrics_upload false`.",
web_url.trim_end_matches('/'),
sharing.now_words()
)
}
#[cfg(test)]
mod k2_review_tests;
#[cfg(test)]
mod tests;