- TalibPatternPanel: pattern checkboxes, detect button, results summary, clear-all and per-pattern delete
- TrainingPanel: model type selector, dataset info, start training, polling, run history
- ModelSelector: dropdown of completed runs, wired into PredictionPanel for model switching
- page.tsx: integrate all three panels into sidebar, wire callbacks (model load, annotations refresh)
- tasks.md: mark all 39 tasks complete
- Archived change to openspec/changes/archive/2026-02-17-ml-db-consolidation/
- Created new postgres-data-layer spec with PostgreSQL connection, schema definitions, Drizzle migrations, npm deps, and SQLite migration requirements
- Updated docker-deployment spec: Docker Compose now PostgreSQL-based (postgres dependency, ml-data volume, DATABASE_URL); env vars updated (DATABASE_URL added, DATABASE_PATH removed); database persistence updated to PostgreSQL volumes; health check updated to PostgreSQL
- Updated ml-training spec: added database name scenario (candle_annotator) and new direct annotation data access requirement
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
- Archived change to openspec/changes/archive/2026-02-17-line-rectangle-annotations/
- Updated annotation-tools spec: added rectangle tool mode, TrendLine plugin rendering, line hit testing, line selection handles; updated line drawing and delete requirements; removed SVG overlay rendering
- Created new rectangle-annotation spec with full requirements for rectangle drawing, rendering, hit testing, selection, deletion, and database storage
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
- Convert numpy.int64 to Python int before passing to SQLAlchemy queries
- Prevents psycopg2.ProgrammingError: can't adapt type 'numpy.int64'
- Applied to get_candles(), get_span_annotations(), and get_point_annotations()
- All ML service database access tests now passing successfully
- Updated .env to use DATABASE_URL instead of DATABASE_PATH
- Tested all API endpoints: health, charts, candles, span annotations
- Confirmed JSONB fields work correctly (geometry, sub_spans, model_prediction)
- All 2,836 rows accessible via API
- Database connection pooling working correctly
- Created scripts/migrate-sqlite-to-postgres.py as alternative to TypeScript version
- Handles all type conversions: timestamps, booleans, and JSONB fields
- Successfully migrated all 2,836 rows from SQLite to PostgreSQL
- Verified data integrity: all 6 tables migrated correctly
- Charts: 1, Candles: 2,592, Annotations: 4, Span annotations: 223
- Add hitTest, setSelected, attached/detached lifecycle methods to TrendLine
- Add preview mode support with dashed lines and reduced opacity
- Draw selection handles on endpoints when selected
- Create RectangleDrawingPrimitive plugin with full ISeriesPrimitive implementation
- Support preview mode, selection, hit testing, and autoscaling for rectangles
- Set z-order to bottom for rectangles to render behind candlesticks
Tasks completed: 1.1-1.4, 2.1-2.7
- Implement disagreement visual highlighting with distinct colors
- Yellow highlight for 'missed_by_human' predictions
- Orange for 'label_mismatch' disagreements
- Warning icon on disagreement markers
- Add click-to-convert prediction feedback
- Click disagreement predictions to create span annotations
- Auto-fill with predicted label and times
- Set source as 'model_confirmed' or 'model_corrected'
- Add dismiss action for false positive predictions
- Alt+Click or Ctrl+Click to dismiss predictions
- Saves negative annotation with label 'O'
- Records original prediction in model_prediction field
- Filter predictions when 'Show only disagreements' is enabled
- Add disagreement detection logic comparing human annotations vs predictions
- Display prediction summary in PredictionPanel (agreements/disagreements)
- Wire up 'Show only disagreements' filter toggle
- Add loading overlay during prediction fetching
- Update docker-compose.yml with healthchecks for all services
- Update DEPLOYMENT.md with comprehensive ML service setup instructions
- Update README.md with ML pipeline overview and architecture diagrams
- Update CLAUDE_DESCRIPTION.md with v3.0.0 ML integration details
Remaining tasks (11.2, 11.4, 11.5) deferred - core functionality complete
- Add histogram series to CandleChart for per-bar prediction colors (15% opacity)
- Add series markers showing label name and confidence % at prediction span starts
- Implement confidence threshold filtering for both histogram and markers
- Implement label type filtering from PredictionPanel checkboxes
- Implement prediction layer visibility toggle (show/hide)
- Add getVisibleCandles method to CandleChartHandle for on-demand prediction fetching
- Pass prediction state props from page.tsx to CandleChart
Tasks 10.1-10.5 complete.
- Create prediction type definitions in src/types/predictions.ts
- Add prediction state management to page.tsx with caching
- Implement PredictionPanel component with:
- Master visibility toggle
- Model info display (name, version, type, metrics)
- Action buttons (Run on Visible, Predict All)
- Confidence threshold slider
- Label filter checkboxes with per-class metrics
- Disagreement filter toggle
- Prediction summary display
- Model server offline banner
- Add on-demand and batch prediction fetching
- Implement prediction caching by chart and model version
- Add health polling for inference API (30s interval when offline)
- Ensure annotation tools work independently of prediction API
Tasks completed: 9.1-9.5, 12.1-12.3 (59/78 total)
- 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
- Create RandomForestModel and XGBoostModel wrappers with class weight support
- Implement temporal and random train/val/test splitting
- Add MLflow experiment tracking with full parameter and metric logging
- Create evaluation module for confusion matrix, feature importance, and classification reports
- Implement model training with sklearn/xgboost flavor logging and optional registry registration
- Store training run metadata in PostgreSQL
- Wire training stage into pipeline.py orchestrator
- Support both RandomForest and XGBoost models with configurable hyperparameters
- Add SpanAnnotation and SpanLabelType interfaces to page.tsx
- Add span-related state: spanAnnotations, selectedSpanId, spanLabelTypes
- Add fetchSpanAnnotations() and fetchSpanLabelTypes() data fetching functions
- Load span annotations and label types when chart changes
- Add "Span" tool button to Toolbox component with RectangleHorizontal icon
- Mark Section 5 tasks (5.1-5.5) as complete in tasks.md
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
- Created SpanRectanglePrimitive.ts implementing ISeriesPrimitive interface
- Implemented updateAllViews() with coordinate conversion from data-space to pixel-space
- Added semi-transparent rectangle rendering with configurable opacity
- Implemented label tag rendering above rectangles showing pattern names
- Added hitTest() for click detection within span bounds
- Implemented highlight state with thicker borders and increased opacity
- Set zOrder to 'bottom' to render rectangles behind candlesticks
- Completed Section 4 tasks (4.1-4.6) from span-annotation specification
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
- Verified ChartSelector uses theme-aware classes
- Tested full workflow: upload, chart creation, switching, annotation scoping
- Verified migration creates default chart with existing data
- Tested chart deletion with cascade delete of candles/annotations
- Tested edge cases: duplicate filenames, deleting last chart, upload with no charts
- Build passes with no type errors
- Add activeChartId/charts state to page.tsx with chart fetching on mount
- ChartSelector integrated in sidebar between header and file upload
- CandleChart and SvgOverlay fetch data scoped by activeChartId
- FileUpload returns chart info, auto-selects new chart after upload
- Annotation create/delete flows include chart_id
- Export scoped by activeChartId
- Toolbox receives activeChartId prop
- GET /api/candles accepts ?chartId= with fallback to most recent chart
- GET /api/annotations accepts ?chartId= with fallback to most recent chart
- POST /api/annotations now requires chart_id in request body
- GET /api/export accepts ?chartId= to scope exported annotations
- DELETE /api/annotations supports optional chartId scoping
- POST /api/upload now creates a chart named from the CSV filename
- Duplicate names get numeric suffix (e.g., btc-daily-2)
- Candles inserted with chart_id instead of replacing all data
- Response includes chart id and name