diff --git a/crates/mem-store/src/agent_repo.rs b/crates/mem-store/src/agent_repo.rs index db932d0..adf53ed 100644 --- a/crates/mem-store/src/agent_repo.rs +++ b/crates/mem-store/src/agent_repo.rs @@ -1,10 +1,10 @@ use anyhow::Result; -use sqlx::PgPool; +use sqlx::{PgPool, FromRow}; use uuid::Uuid; use serde::{Deserialize, Serialize}; use chrono::{DateTime, Utc}; -#[derive(Debug, Clone, Serialize, Deserialize)] +#[derive(Debug, Clone, Serialize, Deserialize, FromRow)] pub struct AgentPrompt { pub id: Uuid, pub project_id: String, @@ -22,7 +22,7 @@ pub struct AgentPrompt { pub updated_at: DateTime, } -#[derive(Debug, Clone, Serialize, Deserialize)] +#[derive(Debug, Clone, Serialize, Deserialize, FromRow)] pub struct AgentSkill { pub id: Uuid, pub project_id: String, @@ -39,7 +39,7 @@ pub struct AgentSkill { pub updated_at: DateTime, } -#[derive(Debug, Clone, Serialize, Deserialize)] +#[derive(Debug, Clone, Serialize, Deserialize, FromRow)] pub struct AgentDecision { pub id: Uuid, pub project_id: String, @@ -59,7 +59,7 @@ pub struct AgentDecision { pub updated_at: DateTime, } -#[derive(Debug, Clone, Serialize, Deserialize)] +#[derive(Debug, Clone, Serialize, Deserialize, FromRow)] pub struct RolePromptMapping { pub id: Uuid, pub project_id: String, @@ -71,7 +71,7 @@ pub struct RolePromptMapping { pub updated_at: DateTime, } -#[derive(Debug, Clone, Serialize, Deserialize)] +#[derive(Debug, Clone, Serialize, Deserialize, FromRow)] pub struct AgentMetrics { pub id: Uuid, pub project_id: String, diff --git a/tests/agent_memory_api_platform_engineer.rs b/tests/agent_memory_api_platform_engineer.rs index bbb7df2..6e78ca6 100644 --- a/tests/agent_memory_api_platform_engineer.rs +++ b/tests/agent_memory_api_platform_engineer.rs @@ -233,15 +233,33 @@ Output JSON with: // Validate error schema is consistent let error_schema = &api_spec["components"]["schemas"]["Error"]; - assert!(error_schema["required"].as_array().unwrap().contains(&Value::String("code".to_string()))); - assert!(error_schema["required"].as_array().unwrap().contains(&Value::String("message".to_string()))); + assert!(error_schema["required"] + .as_array() + .unwrap() + .contains(&Value::String("code".to_string()))); + assert!(error_schema["required"] + .as_array() + .unwrap() + .contains(&Value::String("message".to_string()))); // Validate naming consistency (snake_case) - assert!(api_spec["paths"]["/memory/agents/{project_id}/prompts"]["post"]["operationId"].as_str().unwrap().contains("createPrompt")); - assert!(api_spec["paths"]["/memory/agents/{project_id}/roles/{role_name}/prompts"]["get"]["operationId"].as_str().unwrap().contains("getRolePrompts")); + assert!( + api_spec["paths"]["/memory/agents/{project_id}/prompts"]["post"]["operationId"] + .as_str() + .unwrap() + .contains("createPrompt") + ); + assert!( + api_spec["paths"]["/memory/agents/{project_id}/roles/{role_name}/prompts"]["get"] + ["operationId"] + .as_str() + .unwrap() + .contains("getRolePrompts") + ); // Validate backward compatibility: all fields are optional except required ones - let create_prompt_schema = &api_spec["paths"]["/memory/agents/{project_id}/prompts"]["post"]["requestBody"]["content"]["application/json"]["schema"]; + let create_prompt_schema = &api_spec["paths"]["/memory/agents/{project_id}/prompts"] + ["post"]["requestBody"]["content"]["application/json"]["schema"]; assert_eq!( create_prompt_schema["required"].as_array().unwrap(), &vec![ @@ -329,8 +347,16 @@ Output JSON with: }); assert_eq!(rate_limited_response["status"], 429); - assert_eq!(rate_limited_response["error"]["code"], "rate_limit_exceeded"); - assert!(rate_limited_response["headers"]["Retry-After"].as_i64().unwrap() > 0); + assert_eq!( + rate_limited_response["error"]["code"], + "rate_limit_exceeded" + ); + assert!( + rate_limited_response["headers"]["Retry-After"] + .as_i64() + .unwrap() + > 0 + ); println!("✓ Rate limiting communication validated"); } @@ -396,8 +422,13 @@ Output JSON with: }); assert_eq!(deprecation_plan["lifecycle"]["runway_days"], 365); - assert!(deprecation_plan["signals"]["deprecation_header"].as_str().unwrap().contains("Deprecation")); - assert!(deprecation_plan["monitoring"]["track_usage_by_consumer"].as_bool().unwrap()); + assert!(deprecation_plan["signals"]["deprecation_header"] + .as_str() + .unwrap() + .contains("Deprecation")); + assert!(deprecation_plan["monitoring"]["track_usage_by_consumer"] + .as_bool() + .unwrap()); println!("✓ Deprecation lifecycle validated"); } @@ -481,11 +512,30 @@ Output JSON with: // Validate all requirements assert!(role_requirements["requirements"]["contract_first"]["openapi_spec"] == "required"); - assert!(role_requirements["requirements"]["backward_compatibility"]["no_silent_breaking_changes"].as_bool().unwrap()); - assert!(role_requirements["requirements"]["error_handling"]["consistent_structure"].as_bool().unwrap()); - assert!(role_requirements["requirements"]["rate_limiting"]["communicated_headers"].as_bool().unwrap()); - assert!(role_requirements["requirements"]["sdk_and_docs"]["generated_from_spec"].as_bool().unwrap()); - assert!(role_requirements["requirements"]["idempotency"]["write_operations_idempotent"].as_bool().unwrap()); + assert!(role_requirements["requirements"]["backward_compatibility"] + ["no_silent_breaking_changes"] + .as_bool() + .unwrap()); + assert!( + role_requirements["requirements"]["error_handling"]["consistent_structure"] + .as_bool() + .unwrap() + ); + assert!( + role_requirements["requirements"]["rate_limiting"]["communicated_headers"] + .as_bool() + .unwrap() + ); + assert!( + role_requirements["requirements"]["sdk_and_docs"]["generated_from_spec"] + .as_bool() + .unwrap() + ); + assert!( + role_requirements["requirements"]["idempotency"]["write_operations_idempotent"] + .as_bool() + .unwrap() + ); println!("✓ API Platform Engineer role requirements validated"); } @@ -495,7 +545,11 @@ Output JSON with: // Agent prompts aligned with API Platform Engineer role let agent_prompts = vec![ ("contract-review", CONTRACT_FIRST_PROMPT, "extraction"), - ("compatibility-check", BACKWARD_COMPATIBILITY_PROMPT, "reasoning"), + ( + "compatibility-check", + BACKWARD_COMPATIBILITY_PROMPT, + "reasoning", + ), ("sdk-generation", SDK_GENERATION_PROMPT, "generation"), ]; @@ -508,7 +562,10 @@ Output JSON with: }); assert!(!prompt["template"].as_str().unwrap().is_empty()); - assert!(prompt["template"].as_str().unwrap().contains("{{") || prompt["template"].as_str().unwrap().contains("output")); + assert!( + prompt["template"].as_str().unwrap().contains("{{") + || prompt["template"].as_str().unwrap().contains("output") + ); } println!("✓ Agent prompts for API Platform Engineer validated"); @@ -541,7 +598,10 @@ Output JSON with: assert_eq!(engineer_prompts.len(), 3); // Prompts ordered by priority - assert!(engineer_prompts[0]["priority"].as_i64().unwrap() < engineer_prompts[1]["priority"].as_i64().unwrap()); + assert!( + engineer_prompts[0]["priority"].as_i64().unwrap() + < engineer_prompts[1]["priority"].as_i64().unwrap() + ); println!("✓ Role-to-prompt mapping consistency validated"); }