use schemars::JsonSchema;
use serde::Deserialize;
#[derive(Debug, Deserialize, JsonSchema)]
pub struct MemGetParams {
pub key: String,
}
#[derive(Debug, Deserialize, JsonSchema)]
pub struct MemQueryParams {
pub query: String,
#[serde(default = "default_mode")]
pub mode: String,
#[serde(default = "default_limit")]
pub limit: usize,
}
fn default_mode() -> String {
"text".to_string()
}
fn default_limit() -> usize {
20
}
#[derive(Debug, Deserialize, JsonSchema)]
pub struct MemBootstrapParams {
#[serde(default)]
pub context_files: Vec<String>,
}
fn default_payload() -> serde_json::Value {
serde_json::Value::Object(serde_json::Map::new())
}
fn default_priority() -> String {
"Normal".to_string()
}
fn default_action() -> String {
"write".to_string()
}
#[derive(Debug, Deserialize, JsonSchema)]
pub struct MemSetParams {
#[schemars(description = "\
Action to perform: \"write\" (default, create or update a record), \
\"confirm\" (confirm a gotcha for hook enforcement), \
\"delete\" (tombstone a gotcha record).")]
#[serde(default = "default_action")]
pub action: String,
#[schemars(description = "\
Namespaced key. Patterns: \
file:src/payments/stripe.go | \
gotcha:stripe-idempotency-key-required | \
decision:unified-retry-strategy | \
dev_note:deployment-checklist")]
pub key: String,
#[schemars(description = "\
Human-readable text (tantivy-indexed). \
Gotcha: '{rule} because {reason}'. \
File: purpose sentence starting with a verb. \
Decision: 'We use X because Y'. \
DevNote: freeform observation. \
Not required for confirm or delete actions.")]
#[serde(default)]
pub value: String,
#[schemars(description = "\
Exactly one of: File | Gotcha | Decision | DevNote. \
Not required for confirm or delete actions.")]
#[serde(default)]
pub category: String,
#[schemars(description = "\
Structured payload as a JSON object. \
Gotcha: {rule:string, reason:string, severity:Critical|High|Normal|Low, \
affected_files:[string], ref_url:null, discovered_session:0, confirmed:false}. \
File: {path:string, purpose:string, entry_points:[string], imports:[string], \
gotcha_keys:[string], decision_keys:[string], todos:[], \
unsafe_count:0, unwrap_count:0, change_frequency:0, \
last_author:null, is_hotspot:false, content_hash:null, line_count:0}. \
Decision: {summary:string, rationale:string}. \
DevNote or confirm/delete: empty object {}.")]
#[serde(default = "default_payload")]
pub payload: serde_json::Value,
#[schemars(description = "Optional list of lowercase tag strings. Empty array is fine.")]
#[serde(default)]
pub tags: Vec<String>,
#[schemars(description = "Exactly one of: Normal | High | Critical | Low. Default: Normal.")]
#[serde(default = "default_priority")]
pub priority: String,
}