feat: declarative pipeline config, non-blocking Scene VLM, rust_asrx

Consolidated snapshot (previously WIP in working tree).

- core/pipeline_config: new module loading config/pipeline_flows.json as the
  source of truth for stage execution mode (parallel/blocking) and dependencies
- worker/job_worker: dispatch Scene VLM to a background task when the stage is
  declared parallel, unblocking the worker poll loop; resolve processor
  dependencies from pipeline_flows.json (fallback to built-in)
- config/pipeline_flows.json: asrx depends on [cut, asr]
- scripts/fix_stuck_jobs: fix UTC timezone comparison, raise default threshold
  to 6h, skip jobs with recent processor activity
- rust_asrx: Rust speaker diarization CLI + processor wiring
- processor metadata helper; fast_face_clustering script; file_progress pipeline
  API; scan API; VAD updates
This commit is contained in:
Accusys
2026-10-15 13:01:12 +08:00
parent 667e279768
commit 882e31ab96
76 changed files with 10117 additions and 300 deletions
@@ -0,0 +1,413 @@
# Pipeline Configuration Guide
**Version**: 1.0.0
**Last Updated**: 2026-10-14
---
## 📋 Overview
Pipeline configuration defines the processing flow for video analysis tasks. This configuration is stored in `config/pipeline_flows.json` and managed through the Admin Panel.
---
## 🎯 Configuration Structure
### Main Configuration
```json
{
"version": "1.0.0",
"enabled": true,
"max_concurrent_stages": 3,
"default_timeout_secs": 3600,
"flows": { ... }
}
```
| Field | Type | Description |
|-------|------|-------------|
| `version` | String | Configuration schema version |
| `enabled` | Boolean | Enable/disable pipeline processing |
| `max_concurrent_stages` | Integer | Maximum stages running concurrently |
| `default_timeout_secs` | Integer | Default timeout for all stages |
| `flows` | Object | Pipeline flow definitions |
---
## 🔄 Pipeline Flow
### Flow Definition
```json
{
"name": "Video Registration Pipeline",
"description": "Complete video processing pipeline",
"version": "1.0.0",
"enabled": true,
"stages": [ ... ],
"dependencies": [ "cut", "asr" ]
}
```
| Field | Type | Description |
|-------|------|-------------|
| `name` | String | Human-readable flow name |
| `description` | String | Detailed description |
| `version` | String | Flow version |
| `enabled` | Boolean | Enable/disable this flow |
| `stages` | Array | List of processing stages |
| `dependencies` | Array | Optional: Required flows |
---
## 📦 Pipeline Stage
### Stage Definition
```json
{
"name": "face",
"processor_type": "face",
"description": "Face detection and tracking",
"required": true,
"enabled": true,
"timeout_secs": 7200,
"tool": { ... },
"condition": { ... },
"on_failure": "continue",
"parameters": { ... }
}
```
| Field | Type | Required | Description |
|-------|------|----------|-------------|
| `name` | String | ✅ | Stage identifier (unique in flow) |
| `processor_type` | String | ✅ | Processor type (cut, asr, face, ocr, etc.) |
| `description` | String | ❌ | Human-readable description |
| `required` | Boolean | ❌ | Stop pipeline if this stage fails (default: false) |
| `enabled` | Boolean | ❌ | Enable/disable this stage (default: true) |
| `timeout_secs` | Integer | ❌ | Stage-specific timeout |
| `tool` | Object | ❌ | Tool selection and parameters |
| `condition` | Object | ❌ | Execution conditions |
| `on_failure` | String | ❌ | Failure handling: "continue", "stop", "retry" |
| `parameters` | Object | ❌ | Processor-specific parameters |
---
## 🛠️ Tool Selection
### Tool Definition
```json
{
"name": "swift_face",
"priority": 0,
"description": "Apple Vision framework face detection",
"parameters": {
"min_confidence": 0.5,
"min_size": 1
},
"usage_notes": "Uses Apple Neural Engine for acceleration"
}
```
| Field | Type | Required | Description |
|-------|------|----------|-------------|
| `name` | String | ✅ | Tool name (swift_face, python_whisper, etc.) |
| `priority` | Integer | ❌ | Selection priority (0 = highest) |
| `description` | String | ❌ | Tool description |
| `parameters` | Object | ❌ | Tool-specific parameters |
| `usage_notes` | String | ❌ | Usage instructions and notes |
### Priority System
- **0**: Highest priority (preferred tool)
- **1-99**: Lower priority (fallback tools)
- Lower numbers = higher priority
---
## 🎛️ Execution Conditions
### Condition Definition
```json
{
"depends_on": "cut",
"skip_if_exists": "*.cut.json",
"run_if_missing": "*.face.json"
}
```
| Field | Type | Description |
|-------|------|-------------|
| `depends_on` | String | Run only after specified stage completes |
| `skip_if_exists` | String | Skip if output file exists (glob pattern) |
| `run_if_missing` | String | Run only if output file is missing |
### Examples
**Skip if already processed**:
```json
{
"skip_if_exists": "*.face.json"
}
```
**Run after dependency**:
```json
{
"depends_on": "cut"
}
```
**Conditional execution**:
```json
{
"depends_on": "asr",
"skip_if_exists": "*.asrx.json"
}
```
---
## 📚 Available Processors
### Frame Pipeline
Processors that analyze individual frames:
| Processor | Type | Description | Tools |
|-----------|------|-------------|-------|
| **face** | Frame | Face detection and tracking | swift_face, python_insightface |
| **ocr** | Frame | Text extraction | paddleocr, swift_ocr |
| **pose** | Frame | Body pose estimation | swift_pose, mediapipe |
| **hand** | Frame | Hand detection | swift_hand, mediapipe |
| **appearance** | Frame | Person appearance analysis | rust_appearance |
| **face_cluster** | Frame | Face clustering | rust_face_cluster |
### Time Pipeline
Processors that analyze time-based data:
| Processor | Type | Description | Tools |
|-----------|------|-------------|-------|
| **cut** | Time | Scene cut detection | rust_cut, ffmpeg, python_scenedetect |
| **asr** | Time | Speech recognition | whisper_mlx, whisper.cpp |
| **asrx** | Time | Speaker diarization | pyannote_diarization |
| **scene** | Time | Scene VLM analysis | gemma_vlm, llava |
---
## 🛠️ Tool Parameters Reference
### Face Detection (swift_face)
```json
{
"min_confidence": 0.5,
"min_size": 1,
"model": "facenet512.mlpackage"
}
```
| Parameter | Type | Default | Description |
|-----------|------|---------|-------------|
| `min_confidence` | Float | 0.5 | Minimum confidence threshold (0.0-1.0) |
| `min_size` | Integer | 1 | Minimum face size in pixels |
| `model` | String | "facenet512.mlpackage" | Face recognition model |
---
### ASR (whisper_mlx)
```json
{
"model": "small",
"language": "auto",
"chunk_size": 300
}
```
| Parameter | Type | Default | Description |
|-----------|------|---------|-------------|
| `model` | String | "small" | Whisper model size (tiny/base/small/medium/large) |
| `language` | String | "auto" | Language code or "auto" for detection |
| `chunk_size` | Integer | 300 | Audio chunk size in seconds |
---
### OCR (swift_ocr)
```json
{
"recognition_level": "accurate",
"uses_language_correction": true
}
```
| Parameter | Type | Default | Description |
|-----------|------|---------|-------------|
| `recognition_level` | String | "accurate" | Recognition accuracy: "fast" or "accurate" |
| `uses_language_correction` | Boolean | true | Enable language correction |
| `supported_languages` | Array | [...] | Supported languages (auto-detected) |
**Note**: Uses Apple Vision Framework VNRecognizeTextRequest with ANE acceleration. 2.5x faster than Python (2s vs 5s).
---
### Scene VLM (gemma_vlm)
```json
{
"max_tokens": 900,
"temperature": 0.1,
"output_language": "zh-TW"
}
```
| Parameter | Type | Default | Description |
|-----------|------|---------|-------------|
| `max_tokens` | Integer | 900 | Maximum output tokens |
| `temperature` | Float | 0.1 | Sampling temperature (0.0-1.0) |
| `output_language` | String | "en" | Output language for descriptions |
---
### Cut Detection (rust_cut)
```json
{
"min_scene_duration": 0.5,
"threshold": 0.3
}
```
| Parameter | Type | Default | Description |
|-----------|------|---------|-------------|
| `min_scene_duration` | Float | 0.5 | Minimum scene duration in seconds |
| `threshold` | Float | 0.3 | Detection threshold (0.0-1.0) |
---
## 🚀 Pipeline Flows
### Register Flow
Complete video processing pipeline:
1. **cut** - Scene cut detection
2. **asr** - Speech recognition
3. **face** - Face detection
4. **ocr** - Text extraction
5. **scene** - Scene VLM analysis (depends on cut)
6. **asrx** - Speaker diarization (depends on asr)
### Reprocess Flow
Selective reprocessing for specific processors.
### Phase1 Pack Flow
Package Phase 1 results for delivery.
---
## 📝 Examples
### Basic Configuration
```json
{
"name": "face",
"processor_type": "face",
"enabled": true,
"tool": {
"name": "swift_face",
"priority": 0
}
}
```
### Conditional Execution
```json
{
"name": "asrx",
"processor_type": "asrx",
"condition": {
"depends_on": "asr",
"skip_if_exists": "*.asrx.json"
}
}
```
### Multiple Tool Fallback
```json
{
"name": "face",
"processor_type": "face",
"tools": [
{
"name": "swift_face",
"priority": 0,
"description": "Preferred: ANE accelerated"
},
{
"name": "python_insightface",
"priority": 1,
"description": "Fallback: CPU-based"
}
]
}
```
---
## ⚠️ Important Notes
1. **Tool Priority**: Lower numbers = higher priority
2. **Required Stages**: Set `required: true` to stop pipeline on failure
3. **Timeout**: Default is 3600 seconds (1 hour)
4. **Dependencies**: Use `depends_on` for stage ordering
5. **Skip Logic**: Use `skip_if_exists` to avoid reprocessing
---
## 🔍 Troubleshooting
### Stage Not Running
- Check if `enabled: true`
- Check `skip_if_exists` condition
- Check `depends_on` dependency
- Check processor logs
### Tool Selection Failed
- Check tool `priority` values
- Check tool availability
- Check tool parameters
- Check processor logs
### Timeout Issues
- Increase `timeout_secs`
- Check system resources
- Check video file size
- Check processor logs
---
## 📚 Related Documentation
- [Processor Tools Reference](./OPERATIONS/Processor_Commands_Reference.md)
- [Tool Selector System](./DESIGN/Tool_Selector_V1.0.md)
- [Admin Config API](./API_WORKSPACE/modules/admin_config_api.md)
---
**Last Updated**: 2026-10-14
**Maintainer**: Core Team