---
estimated_steps: 14
estimated_files: 2
skills_used: []
---

# T01: Generalize scorer with stage config registry and update variant generator

Build the STAGE_CONFIGS registry in scorer.py that maps each pipeline stage (2-5) to its scoring rubric, dimensions list, format markers, fixture key requirements, prompt file name, and output schema class. Generalize ScoreResult to use a `scores: dict[str, float]` field instead of 5 named fields (keep backward compat via properties). Add a `score_stage_output()` method to ScoreRunner that accepts arbitrary stage output + input and scores using the stage's rubric. Update variant_generator.py to accept format markers as a parameter rather than using the hardcoded `_FORMAT_MARKERS` list, and generalize the meta-prompt to work for any stage (not just synthesis).

## Context

The existing scorer has a hardcoded `SCORING_RUBRIC` with 5 stage-5 dimensions (structural, content_specificity, voice_preservation, readability, factual_fidelity). `ScoreResult` has these as named float fields. The variant generator has hardcoded `_FORMAT_MARKERS = ['SynthesisResult', '"pages"', 'body_sections', 'title', 'summary']` and a `VARIANT_META_PROMPT` that references 'synthesis prompt' language.

Stages 2-4 need different rubrics:
- Stage 2 (segmentation): coverage_completeness, topic_specificity, boundary_accuracy, summary_quality
- Stage 3 (extraction): moment_richness, timestamp_accuracy, content_type_correctness, summary_actionability, plugin_normalization  
- Stage 4 (classification): category_accuracy, tag_completeness, tag_specificity, coverage, no_overlap

Format markers per stage:
- Stage 2: `'segments'`, `'start_index'`, `'end_index'`, `'topic_label'`
- Stage 3: `'moments'`, `'content_type'`, `'raw_transcript'`, `'plugins'`
- Stage 4: `'classifications'`, `'moment_index'`, `'topic_category'`, `'topic_tags'`
- Stage 5: `'SynthesisResult'`, `'"pages"'`, `'body_sections'`, `'title'`, `'summary'` (existing)

Prompt files: `stage2_segmentation.txt`, `stage3_extraction.txt`, `stage4_classification.txt`, `stage5_synthesis.txt`
Schemas: `SegmentationResult`, `ExtractionResult`, `ClassificationResult`, `SynthesisResult` (all in `pipeline.schemas`)

## Inputs

- ``backend/pipeline/quality/scorer.py` — existing ScoreRunner, SCORING_RUBRIC, DIMENSIONS, ScoreResult`
- ``backend/pipeline/quality/variant_generator.py` — existing PromptVariantGenerator, VARIANT_META_PROMPT, _FORMAT_MARKERS`
- ``backend/pipeline/schemas.py` — SegmentationResult, ExtractionResult, ClassificationResult, SynthesisResult schemas`

## Expected Output

- ``backend/pipeline/quality/scorer.py` — STAGE_CONFIGS registry, generalized ScoreResult with scores dict, score_stage_output() method on ScoreRunner`
- ``backend/pipeline/quality/variant_generator.py` — generalized generate() accepting format_markers parameter, stage-agnostic VARIANT_META_PROMPT`

## Verification

cd backend && python -c "from pipeline.quality.scorer import STAGE_CONFIGS, ScoreResult, ScoreRunner, DIMENSIONS; assert 2 in STAGE_CONFIGS and 3 in STAGE_CONFIGS and 4 in STAGE_CONFIGS and 5 in STAGE_CONFIGS; r = ScoreResult(scores={'structural': 0.8, 'readability': 0.7}, composite=0.75); print('scorer ok')" && python -c "from pipeline.quality.variant_generator import PromptVariantGenerator; print('generator ok')"
