fix: Face processor now saves status and total_faces to face.json

This commit is contained in:
Accusys
2026-09-26 23:06:11 +08:00
parent 8a736a4103
commit 357e585399
99 changed files with 13881 additions and 1065 deletions
@@ -0,0 +1,149 @@
---
title: Command Queue API Changes - Register/Unregister Now Async
date: 2026-09-23
author: Core Team
status: notification
---
# Command Queue API Changes
## Summary
Register and unregister operations are now processed via a command queue (Kafka-like) instead of synchronously. This prevents "dropped" requests when multiple register operations are submitted while a previous one is still in progress.
## API Changes
### POST /api/v1/files/register
**Before**: Synchronous, returned `RegisterFileResponse` with `file_uuid` populated immediately.
**After**: Returns 202 Accepted with `command_id`. The actual registration happens asynchronously in the worker.
**New Response Fields**:
```json
{
"success": true,
"command_id": "abc123...",
"status": "queued",
"file_uuid": "",
"message": "Register queued (command_id=abc123...)",
...
}
```
- `command_id`: UUID to poll for status
- `status`: `"queued"` | `"running"` | `"completed"` | `"failed"`
- `file_uuid`: Empty until command completes
### POST /api/v1/unregister
**Before**: Had `async_mode` flag; sync mode returned deleted counts.
**After**: Always enqueues. Returns 202 with `command_id`.
**New Response Fields**:
```json
{
"success": true,
"command_id": "def456...",
"message": "Unregister queued (command_id=def456...)",
"file_uuid": "...",
"deleted_*": 0
}
```
- `command_id`: UUID to poll for status
- `deleted_*`: All zero until command completes
### NEW: GET /api/v1/command/:command_id
Poll this endpoint to check command status:
```bash
curl http://localhost:3002/api/v1/command/abc123...
```
**Response**: Full `CommandJob` object:
```json
{
"id": 1,
"command_id": "abc123...",
"job_type": "register",
"file_path": "/path/to/video.mp4",
"file_uuid": "384b0ff44aaaa1f1",
"user_id": null,
"payload": {...},
"status": "completed",
"priority": 0,
"error_count": 0,
"last_error": null,
"retry_count": 0,
"started_at": "2026-09-23T12:00:00Z",
"completed_at": "2026-09-23T12:00:05Z",
"created_at": "2026-09-23T12:00:00Z"
}
```
**Status Values**:
- `pending` - Waiting to be claimed by worker
- `running` - Currently being processed
- `completed` - Finished successfully
- `failed` - Failed (check `last_error`)
## Required Studio Changes
1. **Library index.ts (register)**:
- Do NOT expect `file_uuid` immediately
- Store `command_id` from response
- Poll `GET /api/v1/command/:command_id` until `status === "completed"`
- Then read `file_uuid` from command response
2. **Library index.ts (unregister)**:
- Store `command_id` from response
- Poll until completed if you need confirmation
3. **UI Feedback**:
- Show "Registering..." spinner
- Poll every 2-3 seconds
- Show success/error when command completes
## Migration Timeline
- **2026-09-23**: API changes deployed to production (port 3002)
- **Studio**: Must update to polling pattern before next release
## Example: Polling Pattern
```typescript
async function registerWithPolling(filePath: string) {
const res = await fetch('/api/v1/files/register', {
method: 'POST',
body: JSON.stringify({ file_path: filePath })
});
const data = await res.json();
if (!data.success || !data.command_id) {
throw new Error(data.message);
}
const commandId = data.command_id;
// Poll every 2 seconds
while (true) {
await sleep(2000);
const statusRes = await fetch(`/api/v1/command/${commandId}`);
const status = await statusRes.json();
if (status.status === 'completed') {
return status.file_uuid; // Now available
}
if (status.status === 'failed') {
throw new Error(status.last_error);
}
}
}
```
## Questions?
Contact Core team via GitHub issues or this document's comments.