candle-annotator/openspec/changes/archive/2026-02-20-code-review-fix/specs/prediction-ui/spec.md
Marko Djordjevic 925e7284e3 Archive code-review-fix change and sync specs to main
- Synced 14 capability delta specs to main specs
- Created 6 new main specs: api-authentication, error-boundary, input-validation, security-headers, shared-types
- Updated 8 existing specs with security, validation, and performance requirements
- Archived change to openspec/changes/archive/2026-02-20-code-review-fix/

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-02-20 08:54:59 +01:00

2.3 KiB

ADDED Requirements

Requirement: AbortController for prediction requests

The prediction fetching functions (fetchPredictions, handleFetchBatchPredictions) SHALL use AbortController to cancel previous in-flight requests when a new request is initiated. A ref SHALL hold the current controller. Stale responses SHALL be discarded.

Scenario: Rapid clicks cancel previous request

  • WHEN the user clicks "Run on Visible" twice quickly
  • THEN the first request is aborted and only the second response is rendered

Scenario: Batch prediction cancellation

  • WHEN the user clicks "Predict All" while a previous batch prediction is in progress
  • THEN the previous batch request is aborted

Requirement: Bounded prediction cache

The predictionCacheRef Map SHALL have a maximum size of 100 entries. When the cache exceeds the limit, the oldest entry (first inserted) SHALL be evicted. The cache SHALL function as a simple FIFO bounded map.

Scenario: Cache eviction at limit

  • WHEN the cache has 100 entries and a new prediction result is cached
  • THEN the oldest entry is deleted before the new one is inserted

Scenario: Cache size never exceeds limit

  • WHEN 200 unique prediction ranges are fetched
  • THEN the cache contains at most 100 entries at any point

Requirement: Stable modelInfo reference for cache key

The generateCacheKey function SHALL read modelInfo from a ref (not from the predictionState closure) to prevent stale cache keys.

Scenario: Model change produces correct cache key

  • WHEN the user loads a new model and then runs predictions
  • THEN the cache key includes the new model version (not the old one from a stale closure)

Requirement: Confirmation dialog for delete-all annotations

The "Delete All" annotations action SHALL show a confirmation dialog before executing. The dialog SHALL display "Are you sure you want to delete all annotations?" with "Cancel" and "Delete" buttons.

Scenario: User confirms deletion

  • WHEN the user clicks "Delete All" and then clicks "Delete" in the confirmation dialog
  • THEN all annotations for the active chart are deleted

Scenario: User cancels deletion

  • WHEN the user clicks "Delete All" and then clicks "Cancel" in the confirmation dialog
  • THEN no annotations are deleted