feat: add TraceArtifacts phase + VLM waits for all key_frame.jpg

- Add TraceArtifacts phase to TkgPhase enum (phase 18)
- Report progress as key_frame.jpg/key_face.jpg are created
- VLM trigger now polls until ALL key_frame.jpg files exist
  (was: started after TKG build, before artifacts were ready)
- Add iron rule to AGENTS.md: ask before removing data

Tested: Gamma 8 (27 traces) → 27/27 VLM summaries completed
This commit is contained in:
Accusys
2026-08-24 19:13:11 +08:00
parent d29b4804af
commit 9f12e835b8
43 changed files with 3993 additions and 491 deletions
@@ -0,0 +1,139 @@
# VLM Summary Progress — Studio Team Integration Guide
**Date**: 2026-08-22
**Author**: Core team
**Status**: Ready for Studio implementation
---
## Overview
VLM (Vision Language Model) summary is a new pipeline stage (P5) that generates free-text descriptions of each face trace's key frame. This guide covers how to display VLM summary progress in the Studio frontend.
---
## 1. Scan Status API — New Field
### Endpoint
```
GET /api/v1/stats/file/:file_uuid
```
### New Response Field
```json
{
"vlm_summary": {
"total": 22,
"done": 22
}
}
```
| Field | Type | Description |
|-------|------|-------------|
| `total` | `i64` | Total number of face traces for this file |
| `done` | `i64` | Number of traces with VLM summary generated |
### Usage Example
```typescript
const stats = await fetch(`/api/v1/stats/file/${fileUuid}`).then(r => r.json());
const { total, done } = stats.vlm_summary;
const progress = total > 0 ? (done / total) * 100 : 0;
```
---
## 2. Manual VLM Trigger API
For files that already exist but haven't had VLM summaries generated yet:
### Endpoint
```
POST /api/v1/file/:file_uuid/vlm-summary
```
### Response
```json
{
"success": true,
"message": "VLM summary generation started for 22 traces",
"file_uuid": "9df18017960cd13919185145e59ccf3b",
"total_traces": 22,
"already_done": 0,
"pending": 22
}
```
**Note**: This is non-blocking. The VLM generation runs in the background. Poll the scan status API to track progress.
---
## 3. VLM Summary Content — Trace Profile API
The actual VLM summary text is available via the trace profile endpoint:
### Endpoint
```
GET /api/v1/trace-profile?file_uuid=:file_uuid&trace_id=:trace_id
```
### Response Field
```json
{
"vlm_summary": "The image shows a man standing indoors in front of a table with computer monitors..."
}
```
---
## 4. Suggested UI Implementation
### Progress Indicator (in scan status / deep scan page)
```
VLM Summary: ████████████████████ 22/22 (100%)
```
- Show as a progress bar within the pipeline stages
- Green when `done == total`
- Yellow/amber when `0 < done < total`
- Gray when `total == 0` (no face traces)
### Manual Trigger Button
- Show "Generate VLM Summaries" button when `done < total`
- Disable during generation (poll until `done == total`)
- Show success message when complete
### Trace Card Display
- Show VLM summary text as a description tooltip/card below each face trace
- Truncate to ~120 characters with "Read more" expand
- Show as part of the face trace profile modal
---
## 5. Pipeline Automation
When a new file is registered and processed:
1. Registration → Processing pipeline (CUT, ASR, ASRX, OCR, FACE)
2. Post-processing (P2 Face Tracing, P3 Face Cluster, P4 TKG Build)
3. **P5 VLM Summary** — automatically triggered after TKG Build completes
4. The `vlm_summary` progress will update in real-time via polling
For existing files (pre-P5 deployment), use the manual trigger API.
---
## 6. API Reference Summary
| Endpoint | Method | Purpose |
|----------|--------|---------|
| `/api/v1/stats/file/:uuid` | GET | Get scan status including VLM progress |
| `/api/v1/file/:uuid/vlm-summary` | POST | Manually trigger VLM generation |
| `/api/v1/trace-profile?file_uuid=:f&trace_id=:t` | GET | Get trace profile with vlm_summary text |
---
## 7. Error Handling
- `total == 0`: File has no face traces — VLM is not applicable
- `done < total` after long wait: VLM may be running — continue polling
- API returns `success: false`: Check `message` field for error details