34 lines
2.7 KiB
Markdown
34 lines
2.7 KiB
Markdown
## ADDED Requirements
|
|
|
|
### Requirement: Span annotation JSON export for ML pipeline
|
|
The system SHALL provide a `GET /api/span-annotations/export` endpoint that exports all span annotations for a given chart as JSON in the format expected by the ML pipeline. The output SHALL be a JSON object with an `annotations` array where each entry has: `id`, `start_time` (Unix timestamp), `end_time` (Unix timestamp), `label`, `confidence` (nullable), `outcome` (nullable), and `sub_spans` (nullable). The endpoint SHALL accept an optional `chartId` query parameter.
|
|
|
|
#### Scenario: Export span annotations as JSON
|
|
- **WHEN** GET /api/span-annotations/export?chartId=3 is called
|
|
- **THEN** the system returns a JSON object with all span annotations for chart 3 in the ML pipeline format
|
|
|
|
#### Scenario: Export without chartId
|
|
- **WHEN** GET /api/span-annotations/export is called without chartId
|
|
- **THEN** the system exports span annotations for the most recently created chart
|
|
|
|
### Requirement: Prediction-sourced span annotation creation
|
|
The system SHALL support creating span annotations with a `source` field indicating whether the annotation was created by a human ("human"), confirmed from a model prediction ("model_confirmed"), or corrected from a model prediction ("model_corrected"). The existing POST endpoint for span annotations SHALL accept an optional `source` field (default: "human") and optional `model_prediction` field (object with `label` and `confidence` from the original prediction).
|
|
|
|
#### Scenario: Create human annotation
|
|
- **WHEN** a span annotation is created without a source field
|
|
- **THEN** the source defaults to "human"
|
|
|
|
#### Scenario: Confirm model prediction
|
|
- **WHEN** a user confirms a model prediction as an annotation
|
|
- **THEN** the span annotation is created with source "model_confirmed" and model_prediction containing the original predicted label and confidence
|
|
|
|
#### Scenario: Correct model prediction
|
|
- **WHEN** a user changes the label of a model prediction before saving
|
|
- **THEN** the span annotation is created with source "model_corrected" and model_prediction containing the original predicted label and confidence
|
|
|
|
### Requirement: Negative annotation for dismissed predictions
|
|
The system SHALL support saving negative annotations when a user dismisses a model prediction as "not a pattern". A negative annotation SHALL have label "O", source "human_correction", and a `model_prediction` field recording what the model originally predicted.
|
|
|
|
#### Scenario: Save negative annotation
|
|
- **WHEN** user dismisses a "bull_flag" prediction with confidence 0.72
|
|
- **THEN** the system creates a span annotation with label "O", source "human_correction", and model_prediction `{ "label": "bull_flag", "confidence": 0.72 }`
|