docs: add A-7 decision document to version control

- Decision: POST /api/v1/re-scan is canonical API
- Important: auto_pipeline=false by default (customer requirement)
- Provides manual control and safety over processing pipeline
- Includes workflow examples and Studio Team recommendations

Note: This document was created during the session but not yet committed.
Commit 1ec09457 only included the code changes.
This commit is contained in:
Accusys
2026-10-04 15:10:17 +08:00
parent 3399a137d8
commit 1ca3eb1abe
@@ -0,0 +1,217 @@
# A-7 Decision: re-scan as Canonical API
**Date**: 2026-10-04
**Decision Maker**: Core Team
**Status**: ✅ Confirmed (Updated)
---
## Decision
**`POST /api/v1/re-scan` is the canonical API for file re-processing.**
**IMPORTANT**: `auto_pipeline` is **opt-in** (default: `false`).
Client must explicitly set `auto_pipeline: true` to trigger automatic processing.
---
## API Design
### Request
```json
{
"file_uuid": "string",
"processors": ["asr", "face", ...], // Optional: specific processors
"auto_pipeline": false, // Optional: default false
"face_settings": { // Optional
"min_confidence": 0.5,
"min_size": 30
},
"trigger_source": "string", // Optional: for logging
"reason": "string" // Optional: for logging
}
```
### Response
```json
{
"success": true,
"message": "Re-scan queued: register=...",
"file_uuid": "string",
"unregister_command_id": null,
"register_command_id": "string",
"process_command_id": null
}
```
---
## Rationale
### Why auto_pipeline=false by default?
1. **Customer Requirement**: Client explicitly requested manual control over processing pipeline
2. **Safety**: Prevents unintended re-processing of large datasets
3. **Flexibility**: Allows client to inspect registration results before processing
4. **Cost Control**: Avoids unexpected compute resource usage
### Current Implementation (Updated)
The `re-scan` endpoint (`src/api/files.rs:1366`) implements:
```
re-scan(file_uuid, auto_pipeline=false):
1. Query DB for file_path
2. Call register(file_path, force=true, auto_pipeline=false)
3. Return command_id for tracking
4. If auto_pipeline=true: trigger processing automatically
5. If auto_pipeline=false: client must call process API manually
```
### Workflow Comparison
| Aspect | Manual Mode (auto_pipeline=false) | Auto Mode (auto_pipeline=true) |
|--------|-----------------------------------|--------------------------------|
| **Steps** | re-scan → inspect → process | re-scan (all-in-one) |
| **Control** | ✅ Full control over processors | ⚠️ Default processors only |
| **Safety** | ✅ Inspect before processing | ⚠️ Automatic processing |
| **Cost** | ✅ Predictable | ⚠️ May trigger large jobs |
---
## Advantages over Manual Chain (unregister → register → process)
| Aspect | Manual Chain | re-scan API |
|--------|--------------|-------------|
| **Atomicity** | ❌ Can fail mid-way | ✅ Atomic register command |
| **API Calls** | 3 round-trips | 1 round-trip |
| **Error Handling** | 3 error paths | Single error path |
| **API Key Exposure** | 3 auth validations | 1 auth validation |
---
## Usage Examples
### Manual Mode (Recommended for Production)
```bash
# Step 1: Re-register file
curl -X POST http://localhost:3002/api/v1/re-scan \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d '{"file_uuid": "xxx"}'
# Step 2: Inspect registration results
curl http://localhost:3002/api/v1/file/xxx/probe
# Step 3: Trigger processing manually
curl -X POST http://localhost:3002/api/v1/process \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d '{"file_uuid": "xxx", "processors": ["asr", "face"]}'
```
### Auto Mode (Convenience for Testing)
```bash
# All-in-one: register + auto-process
curl -X POST http://localhost:3002/api/v1/re-scan \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d '{"file_uuid": "xxx", "auto_pipeline": true}'
```
---
## Recommendations
### For Studio Team
1. **B-3 (PeopleView.vue)**: Keep using `/api/v1/file/:uuid/thumbnail` (Core endpoint)
- Add proxy forwarding rule if needed
- Or use Core endpoint directly (already working)
2. **B-4 (LibraryView.vue)**: Replace manual chain with `POST /api/v1/re-scan`
```typescript
// Recommended: Manual mode (safe)
const response = await api.post('/api/v1/re-scan', {
file_uuid: file_uuid
// auto_pipeline defaults to false
});
// Inspect results, then trigger processing
await api.post('/api/v1/process', {
file_uuid: file_uuid,
processors: ['asr', 'face']
});
// OR: Auto mode (convenience, use with caution)
// await api.post('/api/v1/re-scan', {
// file_uuid: file_uuid,
// auto_pipeline: true
// });
```
3. **API Cleanup**: Remove manual chain helper functions from `api/index.ts`
### For Core Team
1. **A-5**: Ensure `install_momentry.sh` includes re-scan in smoketest (already done)
2. **A-6**: Add path traversal protection to thumbnail endpoint
3. **Documentation**: Update API docs to mark re-scan as canonical
---
## Backward Compatibility
- ✅ `unregister` API remains available (backward compatibility)
- ✅ `register` API remains available (backward compatibility)
- ✅ `process` API remains available (backward compatibility)
- ✅ `auto_pipeline=false` by default (safe default)
---
## Timeline
| Milestone | Date |
|-----------|------|
| Core Team decision | 2026-10-04 18:00 |
| Implementation (auto_pipeline opt-in) | 2026-10-04 15:10 |
| Studio Team notification | 2026-10-04 19:00 |
| Frontend migration (B-4) | TBD by Studio Team |
---
## Related Documents
- Requirement: `/Volumes/accusys/admin/Momentry_Release_Requirements_20261004.md`
- Implementation: `src/api/files.rs:1366`
- Test: `M4ProMini:/Users/nextorageai/momentry_core/smoketest.sh` (item 35)
---
## Sign-off
**Core Team**: Confirmed
**Date**: 2026-10-04 15:10
---
## Q3 Response: Thumbnail Endpoint Architecture
**Decision**: Use Core endpoint `/api/v1/file/:uuid/thumbnail` as canonical.
**Rationale**:
1. ✅ Already implemented in Core
2. ✅ No proxy dependency
3. ⚠️ Requires path traversal protection (A-6)
**Implementation**:
1. Core Team: Add path traversal protection to thumbnail endpoint (A-6)
2. Studio Team:
- Option A: Add proxy forwarding rule for `/api/v1/file/:uuid/thumbnail`
- Option B: Use Core endpoint directly (already working in PeopleView.vue)
**Recommendation**: Option B (simpler, no changes needed to PeopleView.vue)