|
| 1 | +version: "1.0.0" |
| 2 | +title: "Snap Pipeline — full orchestrator" |
| 3 | +description: | |
| 4 | + Orchestrates the full Marvel Snap Cybernetic Loop: ingest → classify → reconstruct. |
| 5 | + Runs snap-ingest, then snap-classify, then snap-reconstruct in sequence. |
| 6 | + Uses qwen-reason for orchestration decisions. Sub-recipes handle their own models. |
| 7 | + Reports a pipeline summary on completion. |
| 8 | +
|
| 9 | +instructions: | |
| 10 | + # Role |
| 11 | + You are the snap pipeline orchestrator. You coordinate three sub-recipe phases in |
| 12 | + sequence: ingest, classify, reconstruct. You do not process images or build game |
| 13 | + records yourself — you dispatch to sub-recipes, collect results, and surface the |
| 14 | + pipeline summary. You run on qwen-reason for decision-making. |
| 15 | +
|
| 16 | + # Instructions |
| 17 | + Run the three pipeline phases in sequence. After each phase: check the result. |
| 18 | + If a phase reports 0 items processed (and the previous phase produced output), |
| 19 | + halt and surface the issue — do not proceed with empty data. |
| 20 | +
|
| 21 | + Before classify phase: check valkey "snap:daily_cost". If >= 0.01, halt and report |
| 22 | + cost cap hit — do not run classify or reconstruct. |
| 23 | +
|
| 24 | + # Steps |
| 25 | + 1. Invoke ingest sub-recipe with staging_dir={{ staging_dir }}, queue_dir={{ queue_dir }}. |
| 26 | + Collect: queued_count, skipped_count, errors. |
| 27 | + If queued_count == 0: report "nothing to process" and exit cleanly. |
| 28 | +
|
| 29 | + 2. Check daily cost: read valkey key "snap:daily_cost". If >= 0.01, report cap and halt. |
| 30 | +
|
| 31 | + 3. Invoke classify sub-recipe with queue_dir={{ queue_dir }}, output_dir={{ classified_dir }}, |
| 32 | + confidence_threshold={{ confidence_threshold }}. |
| 33 | + Collect: classified_count, snap_count, not_snap_count, cost_incurred. |
| 34 | + Update valkey "snap:daily_cost" += cost_incurred. |
| 35 | + If snap_count == 0: report "no snap screenshots found" and exit cleanly. |
| 36 | +
|
| 37 | + 4. Invoke reconstruct sub-recipe with classified_dir={{ classified_dir }}, |
| 38 | + output_dir={{ output_dir }}, session_window_minutes={{ session_window_minutes }}. |
| 39 | + Collect: sessions_found, records_built, records_stored, validation_failures. |
| 40 | +
|
| 41 | + 5. Emit pipeline summary JSON. |
| 42 | +
|
| 43 | + # End goal |
| 44 | + Full pipeline run complete. Pipeline summary JSON emitted with counts for all phases. |
| 45 | + Game records stored in qdrant snap-game-records. |
| 46 | +
|
| 47 | + # Narrowing |
| 48 | + Do not skip phases or short-circuit the sequence. |
| 49 | + Do not call external models directly — all model calls happen inside sub-recipes. |
| 50 | + If any sub-recipe returns an error: surface the error with the phase name and halt. |
| 51 | + Daily cost cap is enforced at step 2 — do not bypass it. |
| 52 | +
|
| 53 | +parameters: |
| 54 | + - key: staging_dir |
| 55 | + input_type: string |
| 56 | + requirement: optional |
| 57 | + default: "staging/raw" |
| 58 | + description: "Raw screenshots directory" |
| 59 | + - key: queue_dir |
| 60 | + input_type: string |
| 61 | + requirement: optional |
| 62 | + default: "staging/queued" |
| 63 | + description: "Ingest output / classify input directory" |
| 64 | + - key: classified_dir |
| 65 | + input_type: string |
| 66 | + requirement: optional |
| 67 | + default: "staging/classified" |
| 68 | + description: "Classify output / reconstruct input directory" |
| 69 | + - key: output_dir |
| 70 | + input_type: string |
| 71 | + requirement: optional |
| 72 | + default: "staging/reconstructed" |
| 73 | + description: "Reconstruction output directory for GameRecord JSON files" |
| 74 | + - key: confidence_threshold |
| 75 | + input_type: string |
| 76 | + requirement: optional |
| 77 | + default: "0.7" |
| 78 | + description: "Vision classification confidence threshold" |
| 79 | + - key: session_window_minutes |
| 80 | + input_type: string |
| 81 | + requirement: optional |
| 82 | + default: "10" |
| 83 | + description: "Screenshot grouping window in minutes" |
| 84 | + |
| 85 | +sub_recipes: |
| 86 | + - name: "ingest" |
| 87 | + path: "recipes/snap-ingest.yaml" |
| 88 | + values: {} |
| 89 | + |
| 90 | + - name: "classify" |
| 91 | + path: "recipes/snap-classify.yaml" |
| 92 | + values: {} |
| 93 | + |
| 94 | + - name: "reconstruct" |
| 95 | + path: "recipes/snap-reconstruct.yaml" |
| 96 | + values: {} |
| 97 | + |
| 98 | +extensions: |
| 99 | + developer: |
| 100 | + type: builtin |
| 101 | + name: developer |
| 102 | + timeout: 600 |
| 103 | + valkey: |
| 104 | + name: valkey |
| 105 | + type: streamable_http |
| 106 | + uri: http://host.docker.internal:8110/mcp |
| 107 | + timeout: 120 |
| 108 | + qdrant-shared: |
| 109 | + name: qdrant-shared |
| 110 | + type: streamable_http |
| 111 | + uri: http://host.docker.internal:8102/mcp/ |
| 112 | + timeout: 300 |
| 113 | + |
| 114 | +settings: |
| 115 | + goose_provider: "openai" |
| 116 | + goose_model: "qwen-reason" |
| 117 | + temperature: 0.2 |
| 118 | + |
| 119 | +prompt: | |
| 120 | + Begin snap pipeline. |
| 121 | +
|
| 122 | + Staging dir: {{ staging_dir }} |
| 123 | + Queue dir: {{ queue_dir }} |
| 124 | + Classified dir: {{ classified_dir }} |
| 125 | + Output dir: {{ output_dir }} |
| 126 | + Confidence threshold: {{ confidence_threshold }} |
| 127 | + Session window: {{ session_window_minutes }} minutes |
| 128 | +
|
| 129 | + Run phases in sequence: ingest → classify → reconstruct. |
| 130 | + Check cost cap before classify. Halt if any phase errors. |
| 131 | + Emit pipeline summary JSON on completion. |
| 132 | +
|
| 133 | +response: |
| 134 | + json_schema: |
| 135 | + type: object |
| 136 | + properties: |
| 137 | + pipeline_run_id: |
| 138 | + type: string |
| 139 | + description: "Unique ID for this pipeline run (ISO timestamp)" |
| 140 | + phases: |
| 141 | + type: object |
| 142 | + properties: |
| 143 | + ingest: |
| 144 | + type: object |
| 145 | + properties: |
| 146 | + queued_count: {type: number} |
| 147 | + skipped_count: {type: number} |
| 148 | + errors: {type: number} |
| 149 | + classify: |
| 150 | + type: object |
| 151 | + properties: |
| 152 | + classified_count: {type: number} |
| 153 | + snap_count: {type: number} |
| 154 | + not_snap_count: {type: number} |
| 155 | + cost_incurred: {type: number} |
| 156 | + cost_cap_hit: {type: boolean} |
| 157 | + reconstruct: |
| 158 | + type: object |
| 159 | + properties: |
| 160 | + sessions_found: {type: number} |
| 161 | + records_built: {type: number} |
| 162 | + records_stored: {type: number} |
| 163 | + validation_failures: {type: number} |
| 164 | + total_cost_today: |
| 165 | + type: number |
| 166 | + description: "Running daily cost after this run (from valkey)" |
| 167 | + required: |
| 168 | + - pipeline_run_id |
| 169 | + - phases |
0 commit comments