summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsoryu <soryu@soryu.co>2026-02-13 00:05:33 +0000
committersoryu <soryu@soryu.co>2026-02-13 00:05:33 +0000
commitc91d0b70c8e1174286d78b78b0f30ea7b2543762 (patch)
tree36c270e5513373daa3ab23072af6dd03813678bb
parent355f10964c4dbec24a244a00caba5c17ed23fc65 (diff)
downloadsoryu-makima/makima-jp--remove-memory-from-backend-server-handl-aa8f4089.tar.gz
soryu-makima/makima-jp--remove-memory-from-backend-server-handl-aa8f4089.zip
feat: makima.jp: Remove memory from backend server handlers and routesmakima/makima-jp--remove-memory-from-backend-server-handl-aa8f4089
-rw-r--r--makima/src/server/handlers/directives.rs393
-rw-r--r--makima/src/server/mod.rs4
-rw-r--r--makima/src/server/openapi.rs19
3 files changed, 8 insertions, 408 deletions
diff --git a/makima/src/server/handlers/directives.rs b/makima/src/server/handlers/directives.rs
index f624d82..5f3fceb 100644
--- a/makima/src/server/handlers/directives.rs
+++ b/makima/src/server/handlers/directives.rs
@@ -1,18 +1,17 @@
//! HTTP handlers for directive CRUD and DAG progression.
use axum::{
- extract::{Path, Query, State},
+ extract::{Path, State},
http::StatusCode,
response::IntoResponse,
Json,
};
-use serde::Deserialize;
use uuid::Uuid;
use crate::db::models::{
- BatchSetDirectiveMemoryRequest, CreateDirectiveRequest, CreateDirectiveStepRequest,
- Directive, DirectiveListResponse, DirectiveMemory, DirectiveMemoryListResponse,
- DirectiveStep, DirectiveWithSteps, SetDirectiveMemoryRequest, UpdateDirectiveRequest,
+ CreateDirectiveRequest, CreateDirectiveStepRequest,
+ Directive, DirectiveListResponse,
+ DirectiveStep, DirectiveWithSteps, UpdateDirectiveRequest,
UpdateDirectiveStepRequest, UpdateGoalRequest,
};
use crate::db::repository;
@@ -20,12 +19,6 @@ use crate::server::auth::Authenticated;
use crate::server::messages::ApiError;
use crate::server::state::SharedState;
-/// Query parameters for the memory list endpoint.
-#[derive(Debug, Deserialize)]
-pub struct MemoryListQuery {
- pub category: Option<String>,
-}
-
// =============================================================================
// Directive CRUD
// =============================================================================
@@ -848,381 +841,3 @@ pub async fn update_goal(
}
}
-// =============================================================================
-// Directive Memory CRUD
-// =============================================================================
-
-/// List all memories for a directive, optionally filtered by category.
-#[utoipa::path(
- get,
- path = "/api/v1/directives/{id}/memories",
- params(
- ("id" = Uuid, Path, description = "Directive ID"),
- ("category" = Option<String>, Query, description = "Filter by category"),
- ),
- responses(
- (status = 200, description = "List of memories", body = DirectiveMemoryListResponse),
- (status = 404, description = "Directive not found", body = ApiError),
- (status = 503, description = "Database not configured", body = ApiError),
- ),
- security(("bearer_auth" = []), ("api_key" = [])),
- tag = "Directives"
-)]
-pub async fn list_memories(
- State(state): State<SharedState>,
- Authenticated(auth): Authenticated,
- Path(id): Path<Uuid>,
- Query(query): Query<MemoryListQuery>,
-) -> impl IntoResponse {
- let Some(ref pool) = state.db_pool else {
- return (
- StatusCode::SERVICE_UNAVAILABLE,
- Json(ApiError::new("DB_UNAVAILABLE", "Database not configured")),
- )
- .into_response();
- };
-
- // Verify directive ownership
- match repository::get_directive_for_owner(pool, auth.owner_id, id).await {
- Ok(Some(_)) => {}
- Ok(None) => {
- return (
- StatusCode::NOT_FOUND,
- Json(ApiError::new("NOT_FOUND", "Directive not found")),
- )
- .into_response();
- }
- Err(e) => {
- return (
- StatusCode::INTERNAL_SERVER_ERROR,
- Json(ApiError::new("GET_FAILED", &e.to_string())),
- )
- .into_response();
- }
- }
-
- match repository::list_directive_memories(pool, id, query.category.as_deref()).await {
- Ok(memories) => {
- let total = memories.len() as i64;
- Json(DirectiveMemoryListResponse { memories, total }).into_response()
- }
- Err(e) => {
- tracing::error!("Failed to list memories: {}", e);
- (
- StatusCode::INTERNAL_SERVER_ERROR,
- Json(ApiError::new("LIST_FAILED", &e.to_string())),
- )
- .into_response()
- }
- }
-}
-
-/// Get a single memory entry by key.
-#[utoipa::path(
- get,
- path = "/api/v1/directives/{id}/memories/{key}",
- params(
- ("id" = Uuid, Path, description = "Directive ID"),
- ("key" = String, Path, description = "Memory key"),
- ),
- responses(
- (status = 200, description = "Memory entry", body = DirectiveMemory),
- (status = 404, description = "Not found", body = ApiError),
- (status = 503, description = "Database not configured", body = ApiError),
- ),
- security(("bearer_auth" = []), ("api_key" = [])),
- tag = "Directives"
-)]
-pub async fn get_memory(
- State(state): State<SharedState>,
- Authenticated(auth): Authenticated,
- Path((id, key)): Path<(Uuid, String)>,
-) -> impl IntoResponse {
- let Some(ref pool) = state.db_pool else {
- return (
- StatusCode::SERVICE_UNAVAILABLE,
- Json(ApiError::new("DB_UNAVAILABLE", "Database not configured")),
- )
- .into_response();
- };
-
- // Verify directive ownership
- match repository::get_directive_for_owner(pool, auth.owner_id, id).await {
- Ok(Some(_)) => {}
- Ok(None) => {
- return (
- StatusCode::NOT_FOUND,
- Json(ApiError::new("NOT_FOUND", "Directive not found")),
- )
- .into_response();
- }
- Err(e) => {
- return (
- StatusCode::INTERNAL_SERVER_ERROR,
- Json(ApiError::new("GET_FAILED", &e.to_string())),
- )
- .into_response();
- }
- }
-
- match repository::get_directive_memory(pool, id, &key).await {
- Ok(Some(memory)) => Json(memory).into_response(),
- Ok(None) => (
- StatusCode::NOT_FOUND,
- Json(ApiError::new("NOT_FOUND", "Memory entry not found")),
- )
- .into_response(),
- Err(e) => {
- tracing::error!("Failed to get memory: {}", e);
- (
- StatusCode::INTERNAL_SERVER_ERROR,
- Json(ApiError::new("GET_FAILED", &e.to_string())),
- )
- .into_response()
- }
- }
-}
-
-/// Set (upsert) a single memory entry.
-#[utoipa::path(
- post,
- path = "/api/v1/directives/{id}/memories",
- params(("id" = Uuid, Path, description = "Directive ID")),
- request_body = SetDirectiveMemoryRequest,
- responses(
- (status = 200, description = "Memory entry set", body = DirectiveMemory),
- (status = 404, description = "Directive not found", body = ApiError),
- (status = 503, description = "Database not configured", body = ApiError),
- ),
- security(("bearer_auth" = []), ("api_key" = [])),
- tag = "Directives"
-)]
-pub async fn set_memory(
- State(state): State<SharedState>,
- Authenticated(auth): Authenticated,
- Path(id): Path<Uuid>,
- Json(req): Json<SetDirectiveMemoryRequest>,
-) -> impl IntoResponse {
- let Some(ref pool) = state.db_pool else {
- return (
- StatusCode::SERVICE_UNAVAILABLE,
- Json(ApiError::new("DB_UNAVAILABLE", "Database not configured")),
- )
- .into_response();
- };
-
- // Verify directive ownership
- match repository::get_directive_for_owner(pool, auth.owner_id, id).await {
- Ok(Some(_)) => {}
- Ok(None) => {
- return (
- StatusCode::NOT_FOUND,
- Json(ApiError::new("NOT_FOUND", "Directive not found")),
- )
- .into_response();
- }
- Err(e) => {
- return (
- StatusCode::INTERNAL_SERVER_ERROR,
- Json(ApiError::new("GET_FAILED", &e.to_string())),
- )
- .into_response();
- }
- }
-
- match repository::set_directive_memory(pool, id, &req).await {
- Ok(memory) => Json(memory).into_response(),
- Err(e) => {
- tracing::error!("Failed to set memory: {}", e);
- (
- StatusCode::INTERNAL_SERVER_ERROR,
- Json(ApiError::new("SET_FAILED", &e.to_string())),
- )
- .into_response()
- }
- }
-}
-
-/// Batch set multiple memory entries.
-#[utoipa::path(
- post,
- path = "/api/v1/directives/{id}/memories/batch",
- params(("id" = Uuid, Path, description = "Directive ID")),
- request_body = BatchSetDirectiveMemoryRequest,
- responses(
- (status = 200, description = "Memory entries set", body = Vec<DirectiveMemory>),
- (status = 404, description = "Directive not found", body = ApiError),
- (status = 503, description = "Database not configured", body = ApiError),
- ),
- security(("bearer_auth" = []), ("api_key" = [])),
- tag = "Directives"
-)]
-pub async fn batch_set_memories(
- State(state): State<SharedState>,
- Authenticated(auth): Authenticated,
- Path(id): Path<Uuid>,
- Json(req): Json<BatchSetDirectiveMemoryRequest>,
-) -> impl IntoResponse {
- let Some(ref pool) = state.db_pool else {
- return (
- StatusCode::SERVICE_UNAVAILABLE,
- Json(ApiError::new("DB_UNAVAILABLE", "Database not configured")),
- )
- .into_response();
- };
-
- // Verify directive ownership
- match repository::get_directive_for_owner(pool, auth.owner_id, id).await {
- Ok(Some(_)) => {}
- Ok(None) => {
- return (
- StatusCode::NOT_FOUND,
- Json(ApiError::new("NOT_FOUND", "Directive not found")),
- )
- .into_response();
- }
- Err(e) => {
- return (
- StatusCode::INTERNAL_SERVER_ERROR,
- Json(ApiError::new("GET_FAILED", &e.to_string())),
- )
- .into_response();
- }
- }
-
- match repository::batch_set_directive_memories(pool, id, &req.memories).await {
- Ok(memories) => Json(memories).into_response(),
- Err(e) => {
- tracing::error!("Failed to batch set memories: {}", e);
- (
- StatusCode::INTERNAL_SERVER_ERROR,
- Json(ApiError::new("SET_FAILED", &e.to_string())),
- )
- .into_response()
- }
- }
-}
-
-/// Delete a single memory entry by key.
-#[utoipa::path(
- delete,
- path = "/api/v1/directives/{id}/memories/{key}",
- params(
- ("id" = Uuid, Path, description = "Directive ID"),
- ("key" = String, Path, description = "Memory key"),
- ),
- responses(
- (status = 204, description = "Deleted"),
- (status = 404, description = "Not found", body = ApiError),
- (status = 503, description = "Database not configured", body = ApiError),
- ),
- security(("bearer_auth" = []), ("api_key" = [])),
- tag = "Directives"
-)]
-pub async fn delete_memory(
- State(state): State<SharedState>,
- Authenticated(auth): Authenticated,
- Path((id, key)): Path<(Uuid, String)>,
-) -> impl IntoResponse {
- let Some(ref pool) = state.db_pool else {
- return (
- StatusCode::SERVICE_UNAVAILABLE,
- Json(ApiError::new("DB_UNAVAILABLE", "Database not configured")),
- )
- .into_response();
- };
-
- // Verify directive ownership
- match repository::get_directive_for_owner(pool, auth.owner_id, id).await {
- Ok(Some(_)) => {}
- Ok(None) => {
- return (
- StatusCode::NOT_FOUND,
- Json(ApiError::new("NOT_FOUND", "Directive not found")),
- )
- .into_response();
- }
- Err(e) => {
- return (
- StatusCode::INTERNAL_SERVER_ERROR,
- Json(ApiError::new("GET_FAILED", &e.to_string())),
- )
- .into_response();
- }
- }
-
- match repository::delete_directive_memory(pool, id, &key).await {
- Ok(true) => StatusCode::NO_CONTENT.into_response(),
- Ok(false) => (
- StatusCode::NOT_FOUND,
- Json(ApiError::new("NOT_FOUND", "Memory entry not found")),
- )
- .into_response(),
- Err(e) => {
- tracing::error!("Failed to delete memory: {}", e);
- (
- StatusCode::INTERNAL_SERVER_ERROR,
- Json(ApiError::new("DELETE_FAILED", &e.to_string())),
- )
- .into_response()
- }
- }
-}
-
-/// Clear all memories for a directive.
-#[utoipa::path(
- delete,
- path = "/api/v1/directives/{id}/memories",
- params(("id" = Uuid, Path, description = "Directive ID")),
- responses(
- (status = 204, description = "All memories cleared"),
- (status = 404, description = "Directive not found", body = ApiError),
- (status = 503, description = "Database not configured", body = ApiError),
- ),
- security(("bearer_auth" = []), ("api_key" = [])),
- tag = "Directives"
-)]
-pub async fn clear_memories(
- State(state): State<SharedState>,
- Authenticated(auth): Authenticated,
- Path(id): Path<Uuid>,
-) -> impl IntoResponse {
- let Some(ref pool) = state.db_pool else {
- return (
- StatusCode::SERVICE_UNAVAILABLE,
- Json(ApiError::new("DB_UNAVAILABLE", "Database not configured")),
- )
- .into_response();
- };
-
- // Verify directive ownership
- match repository::get_directive_for_owner(pool, auth.owner_id, id).await {
- Ok(Some(_)) => {}
- Ok(None) => {
- return (
- StatusCode::NOT_FOUND,
- Json(ApiError::new("NOT_FOUND", "Directive not found")),
- )
- .into_response();
- }
- Err(e) => {
- return (
- StatusCode::INTERNAL_SERVER_ERROR,
- Json(ApiError::new("GET_FAILED", &e.to_string())),
- )
- .into_response();
- }
- }
-
- match repository::clear_directive_memories(pool, id).await {
- Ok(_) => StatusCode::NO_CONTENT.into_response(),
- Err(e) => {
- tracing::error!("Failed to clear memories: {}", e);
- (
- StatusCode::INTERNAL_SERVER_ERROR,
- Json(ApiError::new("CLEAR_FAILED", &e.to_string())),
- )
- .into_response()
- }
- }
-}
diff --git a/makima/src/server/mod.rs b/makima/src/server/mod.rs
index b380508..4cb4296 100644
--- a/makima/src/server/mod.rs
+++ b/makima/src/server/mod.rs
@@ -237,10 +237,6 @@ pub fn make_router(state: SharedState) -> Router {
.route("/directives/{id}/steps/{step_id}/fail", post(directives::fail_step))
.route("/directives/{id}/steps/{step_id}/skip", post(directives::skip_step))
.route("/directives/{id}/goal", put(directives::update_goal))
- // Directive memory endpoints
- .route("/directives/{id}/memories", get(directives::list_memories).post(directives::set_memory).delete(directives::clear_memories))
- .route("/directives/{id}/memories/batch", post(directives::batch_set_memories))
- .route("/directives/{id}/memories/{key}", get(directives::get_memory).delete(directives::delete_memory))
// Timeline endpoint (unified history for user)
.route("/timeline", get(history::get_timeline))
// Contract type templates (built-in only)
diff --git a/makima/src/server/openapi.rs b/makima/src/server/openapi.rs
index f049759..c299dfe 100644
--- a/makima/src/server/openapi.rs
+++ b/makima/src/server/openapi.rs
@@ -3,21 +3,21 @@
use utoipa::OpenApi;
use crate::db::models::{
- AddLocalRepositoryRequest, AddRemoteRepositoryRequest, BatchSetDirectiveMemoryRequest,
+ AddLocalRepositoryRequest, AddRemoteRepositoryRequest,
BranchInfo, BranchListResponse, BranchTaskRequest, BranchTaskResponse,
ChangePhaseRequest,
Contract, ContractChatHistoryResponse, ContractChatMessageRecord, ContractEvent,
ContractListResponse, ContractRepository, ContractSummary, ContractWithRelations,
CreateContractRequest, CreateDirectiveRequest, CreateDirectiveStepRequest, CreateFileRequest,
CreateManagedRepositoryRequest, CreateTaskRequest, Daemon, DaemonDirectoriesResponse,
- DaemonDirectory, DaemonListResponse, Directive, DirectiveListResponse, DirectiveMemory,
- DirectiveMemoryListResponse, DirectiveStep, DirectiveSummary, DirectiveWithSteps,
+ DaemonDirectory, DaemonListResponse, Directive, DirectiveListResponse,
+ DirectiveStep, DirectiveSummary, DirectiveWithSteps,
File, FileListResponse, FileSummary,
MergeCommitRequest, MergeCompleteCheckResponse, MergeResolveRequest, MergeResultResponse,
MergeSkipRequest, MergeStartRequest, MergeStatusResponse, MeshChatConversation,
MeshChatHistoryResponse, MeshChatMessageRecord, RepositoryHistoryEntry,
RepositoryHistoryListResponse, RepositorySuggestionsQuery, SendMessageRequest,
- SetDirectiveMemoryRequest, Task,
+ Task,
TaskEventListResponse, TaskListResponse, TaskSummary, TaskWithSubtasks, TranscriptEntry,
UpdateContractRequest, UpdateDirectiveRequest, UpdateDirectiveStepRequest,
UpdateFileRequest, UpdateGoalRequest, UpdateTaskRequest,
@@ -123,13 +123,6 @@ use crate::server::messages::{ApiError, AudioEncoding, StartMessage, StopMessage
directives::fail_step,
directives::skip_step,
directives::update_goal,
- // Directive memory endpoints
- directives::list_memories,
- directives::get_memory,
- directives::set_memory,
- directives::batch_set_memories,
- directives::delete_memory,
- directives::clear_memories,
// Repository history/settings endpoints
repository_history::list_repository_history,
repository_history::get_repository_suggestions,
@@ -226,10 +219,6 @@ use crate::server::messages::{ApiError, AudioEncoding, StartMessage, StopMessage
UpdateGoalRequest,
CreateDirectiveStepRequest,
UpdateDirectiveStepRequest,
- DirectiveMemory,
- DirectiveMemoryListResponse,
- SetDirectiveMemoryRequest,
- BatchSetDirectiveMemoryRequest,
// Repository history schemas
RepositoryHistoryEntry,
RepositoryHistoryListResponse,