feat(api): add span annotation export and feedback loop support

- Add GET /api/span-annotations/export endpoint for ML pipeline JSON/CSV export
- Add source and model_prediction fields to span_annotations schema
- Update POST endpoint to accept source (human/model/human_correction) and model_prediction metadata
- Support negative annotations (label 'O' for user corrections to model predictions)
- Create migration 0005 for new schema fields

Completes tasks 8.1-8.4 of candle-backend change
This commit is contained in:
Marko Djordjevic 2026-02-15 14:35:31 +01:00
parent 205021e810
commit bb1b6d573f
5 changed files with 147 additions and 4 deletions

View file

@ -0,0 +1,11 @@
-- Migration: Add source and model_prediction fields to span_annotations
-- Supports tracking annotation origin and model feedback loop
-- Add source field (defaults to 'human')
-- Possible values: 'human', 'model', 'human_correction'
ALTER TABLE `span_annotations` ADD COLUMN `source` TEXT NOT NULL DEFAULT 'human';
-- Add model_prediction field (nullable JSON)
-- Stores model prediction metadata when user confirms/corrects a prediction
-- Example: {"label": "bull_flag", "confidence": 0.85, "model_version": "xgb_v1"}
ALTER TABLE `span_annotations` ADD COLUMN `model_prediction` TEXT;