DataViewer Ordering Abstractions Implementation Roadmap
Purpose
This roadmap defines a focused refactor that separates ordering concerns for DataViewer stacked lanes.
It introduces a reusable ordering model that decouples:
- metadata ingestion (for example, spike-sorter channel positions)
- sortable value derivation
- ordering policy resolution
- layout request assembly
This roadmap is intended to be completed before Phase 4b in mixed lanes and scaling work.
Relationship to Mixed-Lanes Roadmap
This document is a prerequisite for interactive lane drag-and-drop (Phase 4b) in:
- docs/developer/ui/Plots/DataViewerWidget/mixed_lanes_and_scaling_implementation_roadmap.md
Rationale:
- Phase 4b requires a stable source of truth for lane ordering.
- Current ordering behavior still mixes policy and ingestion concerns.
- A clean ordering abstraction reduces coupling and makes drag/drop persistence rules clearer.
Scope
In scope:
- Introduce ordering-domain abstractions for stackable lane series.
- Separate ingestion from sorting policy.
- Add policy composition with deterministic precedence.
- Add a persisted constraints model in DataViewer state.
- Keep current behavior parity before enabling new constraint types.
Out of scope:
- UI for authoring all rule types (JSON/state API first).
- Full-canvas series reordering semantics.
- Phase 4b drag/drop interaction implementation itself.
Locked Decisions
- Constraint scope (first release): stackable series only.
- Persistence model: ordering rules and constraints are serialized in DataViewerState.
- Conflict policy: explicit lane_order wins; constraints apply to unresolved relative ordering.
Success Criteria
- OpenGLWidget no longer owns ordering policy details.
- Spike-sorter support is one provider in a generic sortable-ranking model.
- Ordering remains deterministic under mixed explicit, relational, and fallback rules.
- Existing Phase 4 behavior remains unchanged after extraction.
- The resulting abstraction directly supports Phase 4b state updates.
High-Level Delivery Order
- Phase A: Baseline behavior lock
- Phase B: Ordering domain model extraction
- Phase C: Ingestion and ranking separation
- Phase D: Policy resolver introduction
- Phase E: Relational constraints model (stackable-only)
- Phase F: UI and renderer decoupling follow-through
- Phase G: Verification matrix and hardening
Phase A: Baseline Behavior Lock
Goal
Create a stable regression harness before refactoring ordering internals.
Tasks
Acceptance Criteria
Phase B: Ordering Domain Model Extraction
Goal
Introduce a normalized ordering input model independent of file format details.
Tasks
Acceptance Criteria
Phase C: Ingestion and Ranking Separation
Goal
Separate spike-sorter file parsing from ordering-policy execution.
Tasks
Acceptance Criteria
Phase D: Policy Resolver Introduction
Goal
Centralize ordering precedence logic in a dedicated resolver.
Resolver precedence
- explicit lane_order
- relational constraints (when present)
- fallback sortable provider ranks
- deterministic tie-break (series type precedence then stable key)
Tasks
Acceptance Criteria
Phase E: Relational Constraints Model (Stackable-Only)
Goal
Add persisted relative-order constraints to support richer semantics.
Example target use case
- Place DigitalEventSeries 2 and 3 above AnalogTimeSeries channel 7.
Tasks
Acceptance Criteria
Phase F: UI and Renderer Decoupling Follow-Through
Goal
Ensure ownership and signal flow align with EditorState architecture.
Tasks
-
The
seriesLaneOverrideChangedsignal already triggers layout invalidation and repaint, so no manual dirty-flag management is needed in the new load/clear methods.New channels loaded after the config is applied land below all explicitly-ordered channels (no
lane_orderoverride →nullopt→ after explicit series in resolver precedence). This is the intended behavior; re-running load rewrites all overrides from scratch. [N/A] F3 – Replace
spike_sorter_configsinLayoutRequestBuildContextwith aSortableRankProvider. Superseded by F2: by converting positions tolane_orderoverrides at load time,LayoutRequestBuildContextnever needs a spike-sorter-specific field at all. TheSortableRankProvidertype alias remains available for future rank providers.[N/A] F4 – Wire
SortableRankProviderthroughapplyOrderingRules. Superseded by F2: the spike-sorter fallback path inapplyOrderingRulesis removed entirely; spike-sorter ordering flows through the existing explicitlane_orderpath.
Acceptance Criteria
Phase G: Verification Matrix and Hardening
Goal
Provide robust confidence for Phase 4b and future ordering features.
Verification matrix
- Explicit lane_order only
- Fallback ranking only
- Constraints only
- Explicit plus constraints
- Constraints plus fallback
- Explicit plus constraints plus fallback
- Shared-lane overlays with mixed series types
Tasks
Acceptance Criteria
Suggested PR Slicing
- PR 1: Baseline tests and ordering domain scaffolding
- PR 2: Spike-sorter parser/rank split
- PR 3: Policy resolver extraction
- PR 4: Relational constraints persistence and solver
- PR 5: Integration cleanup and docs
Definition of Done
The ordering-abstractions roadmap is complete when:
- all phase acceptance criteria are met
- ordering policy is modular and ingestion-agnostic
- deterministic tests cover precedence and conflicts
- mixed-lanes Phase 4 behavior remains intact
- the codebase is ready to begin Phase 4b interactive drag/drop work