docs: studio team guide — face_artifacts completion counts (new API fields)

This commit is contained in:
Accusys
2026-08-16 23:14:10 +08:00
parent dda0b7cc7f
commit 78eb4fb8d9
@@ -0,0 +1,109 @@
# Studio Team Guide: Face Artifact Completion Counts (`face_artifacts`)
> **To**: Studio team (Momentry Studio frontend)
> **From**: Core team
> **Date**: 2026-08-16
> **Status**: Backend done & deployed to production (3002), `build_git_hash dda0b7cc`
## Purpose
When a large file is still being processed (TKG build runs in background), the face
screen shows no indication of progress — thumbnails appear gradually with no
"how many are done / how many are expected" feedback.
Core backend now exposes on-disk **face artifact completion counts** in two API
responses. This document describes the new field and how to display it.
## What was added
Both endpoints now return a `face_artifacts` object:
| Field | Meaning |
|-------|---------|
| `expected_traces` | Total traces expected (from `trace_profiles` table COUNT) |
| `trace_dirs` | `trace_<N>` directories present on disk |
| `trace_profiles` | `trace_profile.json` files present on disk |
| `key_frames` | `key_frame.jpg` files present on disk |
| `key_faces` | `key_face.jpg` files present on disk |
The on-disk counts reflect **actual filesystem state**, so while TKG build is still
running they will be lower than `expected_traces` and grow over time.
## API 1: `GET /api/v1/stats/file/{file_uuid}`
Response now includes (inside the top-level object):
```json
{
"face_artifacts": {
"expected_traces": 4838,
"trace_dirs": 3064,
"trace_profiles": 3064,
"key_frames": 3064,
"key_faces": 3064
}
}
```
## API 2: `POST /api/v1/file/{file_uuid}/traces`
Response now includes:
```json
{
"success": true,
"file_uuid": "...",
"total_traces": 4838,
"face_artifacts": {
"expected_traces": 4838,
"trace_dirs": 3064,
"trace_profiles": 3064,
"key_frames": 3064,
"key_faces": 3064
}
}
```
## Current Studio integration points (read-only references)
| Concern | File / line |
|---------|-------------|
| `FileStats` interface | `/Users/accusys/momentry_studio/src/store.ts:158` |
| `loadFileStats()` parse | `/Users/accusys/momentry_studio/src/store.ts:1042` |
| Face screen data (`get_file_traces`) | `/Users/accusys/momentry_studio/src/views/PeopleView.vue:1616` |
| Existing QC summary (withKeyFrame / withKeyFace) | `/Users/accusys/momentry_studio/src/views/PeopleView.vue:608-615` |
| QC trace summary computation | `/Users/accusys/momentry_studio/src/views/PeopleView.vue:3345-3483` |
> Note: the existing `qcTraceSummary` counts `key_frame`/`key_face` from **DB
> trace profiles**, which for Charade are mostly `null` (4827/4838) because the TKG
> build runs after `load_trace_profiles.py`. The new `face_artifacts` counts actual
> **disk files**, which is the more accurate completion signal.
## Suggested display
Add a compact completion banner on the face screen, e.g. above the trace grid:
```
Face artifacts key_face 3,064 / 4,838 key_frame 3,064 / 4,838 (TKG build in progress)
```
- Use `face_artifacts.key_faces` / `face_artifacts.expected_traces` as the primary
progress indicator.
- When `key_faces === expected_traces` (and `expected_traces > 0`), processing is
complete — show a green/complete state instead of "in progress".
- `expected_traces === 0` means no face traces for this file (hide the banner).
## Suggested frontend changes (in `/Users/accusys/momentry_studio/`)
1. Add `face_artifacts` to the `FileStats` interface (`src/store.ts:158`).
2. Parse `data.face_artifacts` in `loadFileStats()` (`src/store.ts:1042`) into the
interface with sensible defaults (all `0`).
3. In `PeopleView.vue`, when rendering the face screen, read the parsed values and
render the completion banner described above.
4. Optionally refresh on poll (the same timer that refreshes traces) so the counts
update as TKG build progresses.
## Compatibility
- Field is additive — existing Studio builds ignore it without breaking.
- All counts are `i64` (JSON numbers).