From 78169c3bc00b5ba126b6ec2d6bf9647439ea961b Mon Sep 17 00:00:00 2001 From: Accusys Date: Sat, 24 Oct 2026 11:55:30 +0800 Subject: [PATCH] docs: update service management API completion report - Add issue found & fixed section - Document route conflict problem and solution - Clarify public vs protected endpoints - Add authentication requirements for frontend - Update version to 1.1 --- ...6-10-24_service_management_api_complete.md | 61 +++++++++++++------ 1 file changed, 42 insertions(+), 19 deletions(-) diff --git a/docs_v1.0/M4_workspace/2026-10-24_service_management_api_complete.md b/docs_v1.0/M4_workspace/2026-10-24_service_management_api_complete.md index 181fa1d8..3478d2a7 100644 --- a/docs_v1.0/M4_workspace/2026-10-24_service_management_api_complete.md +++ b/docs_v1.0/M4_workspace/2026-10-24_service_management_api_complete.md @@ -1,6 +1,6 @@ --- title: Service Management API Complete -version: 1.0 +version: 1.1 date: 2026-10-24 author: OpenCode status: complete @@ -12,20 +12,34 @@ Enable MarkBaseEngine management UI (Stop/Start/Test buttons) to control inferen ## Summary Successfully implemented service management API for controlling llama.cpp VLM service. All endpoints are working correctly and tested. +**Update (2026-10-24 03:50)**: Fixed route conflict issue. Service management API now fully operational. + +## Issue Found & Fixed + +### Problem +- `/api/v1/mbe/health` was returning 401 Unauthorized +- Root cause: `health::health_routes()` was conflicting with `public_health_routes` +- `health::health_routes()` defines routes without `/api/v1` prefix, causing routing conflicts + +### Solution +- Removed duplicate `health::health_routes()` merge from app router +- `public_health_routes` already contains all health endpoints with correct `/api/v1` prefix +- Moved `service_management::router()` to `protected_routes` for proper authentication + ## Implementation Details ### New API Endpoints -| Endpoint | Method | Purpose | Status | -|----------|--------|---------|--------| -| `/api/v1/mbe/health` | GET | Check VLM service status | ✅ Working | -| `/api/v2/service/start` | POST | Start llama-server | ✅ Working | -| `/api/v2/service/stop` | POST | Stop llama-server | ✅ Working | +| Endpoint | Method | Purpose | Auth | Status | +|----------|--------|---------|------|--------| +| `/api/v1/mbe/health` | GET | Check VLM service status | Public | ✅ Working | +| `/api/v2/service/start` | POST | Start llama-server | Required | ✅ Working | +| `/api/v2/service/stop` | POST | Stop llama-server | Required | ✅ Working | ### Files Changed - `src/api/service_management.rs`: New module with all handlers (start_service, stop_service, mbe_health) - `src/api/mod.rs`: Module declaration -- `src/api/server.rs`: Router integration with public routes +- `src/api/server.rs`: Router integration, fixed route conflict ### Key Technical Decisions @@ -45,23 +59,27 @@ Successfully implemented service management API for controlling llama.cpp VLM se - Extracts model name from response - Returns "offline" if port not in use or HTTP request fails +5. **Route Organization**: + - Public routes (no auth): `/api/v1/health/*`, `/api/v1/mbe/health` + - Protected routes (auth required): `/api/v2/service/*` + ### Testing Results ```bash -# Health check (service running) +# Health check (public, no auth required) GET /api/v1/mbe/health Response: {"status":"ok","model":"gemma-4-12b-it-Q4_K_M.gguf","uptime":0} # Health check (service stopped) Response: {"status":"offline"} -# Stop service -POST /api/v2/service/stop {"name":"mbe"} -Response: {"result":"stopped"} +# Stop service (requires API key) +POST /api/v2/service/start?api_key=... {"name":"mbe"} +Response: {"result":"started","pid":14151} -# Start service -POST /api/v2/service/start {"name":"mbe"} -Response: {"result":"started","pid":72415} +# Start service (requires API key) +POST /api/v2/service/stop?api_key=... {"name":"mbe"} +Response: {"result":"stopped"} ``` ### VLM Verification @@ -77,9 +95,9 @@ The endpoints match the expected API format in Momentry Studio (`AdminView.vue`) ```typescript // Studio expects these endpoints: -start_service: `/api/v2/service/start` ✅ Implemented -stop_service: `/api/v2/service/stop` ✅ Implemented -mbe_health: `/api/v1/mbe/health` ✅ Implemented +start_service: `/api/v2/service/start` ✅ Implemented (protected) +stop_service: `/api/v2/service/stop` ✅ Implemented (protected) +mbe_health: `/api/v1/mbe/health` ✅ Implemented (public) ``` ## Next Steps for Studio Team @@ -90,8 +108,12 @@ mbe_health: `/api/v1/mbe/health` ✅ Implemented - Stop button: Stops llama-server, status changes to "offline" - Start button: Starts llama-server, status changes to "online" - Test button: Sends test request to VLM +3. **Authentication**: + - `/api/v1/mbe/health` is PUBLIC (no API key required) + - `/api/v2/service/start` and `/api/v2/service/stop` require API key + - Frontend should send API key via query param or header -3. **Error Handling**: API returns clear error messages if: +4. **Error Handling**: API returns clear error messages if: - Service already running (start) - Service not running (stop) - VLM not responding (health) @@ -122,4 +144,5 @@ These limitations are acceptable for current use case but can be enhanced in fut | Version | Date | Changes | |---------|------|---------| -| 1.0 | 2026-10-24 | Initial implementation complete | \ No newline at end of file +| 1.0 | 2026-10-24 | Initial implementation | +| 1.1 | 2026-10-24 | Fixed route conflict, moved service_management to protected routes | \ No newline at end of file