Skip to content

Priority sorting is lexicographic — no rank ordering exists for the 5-level scale #2692

Closed

Description

@malibio

Problem Statement

Sorting by task.priority is user-reachable (OrderBy/SortConfig, over json_extract(properties,'$.task.priority')) but is plain lexicographic on the stored string. No rank map exists anywhere in the codebase.

With the old 3-level scale this already produced a wrong order (high, low, medium ascending). Since #2651 widened the field to 5 levels, ascending order is now:

high, highest, low, lowest, medium

This is arguably worse than before — not because it degraded, but because it is plausible enough to look intentional at a glance, where high, low, medium reads as obviously broken.

Proposed Solution

Introduce an explicit rank for the core priority scale (highest=0 … lowest=4) and sort on that rather than the raw string. Open questions the implementation needs to settle:

  • Where the rank lives — a Rust-side map, a generated SQL CASE expression in the order-by clause, or a stored numeric companion column.
  • How user-defined priority values (TaskPriority::User(_), permitted by schema extensibility) rank relative to core ones. Sorting them last, preserving lexicographic order among themselves, is the obvious default.
  • Whether project.priority (still 3-level, see the companion issue) shares the mechanism.

Acceptance Criteria

  • Ascending sort on task.priority returns highest, high, medium, low, lowest
  • User-defined priority values have a defined, documented position in the ordering
  • Tests cover ordering across the full 5-level scale plus at least one user-defined value
  • task.priority's schema description in core_schemas.rs may then legitimately mention sorting (the "and sorting" wording was deliberately removed in Expand core task.priority to a 5-level scale (Highest/High/Medium/Low/Lowest) #2651 because nothing implemented it)

Reference Files

  • packages/core/src/models/core_schemas.rs — task.priority field definition
  • packages/core/src/services/query_service/ — OrderBy/SortConfig handling

Related Issues

Activity

  1. malibio commented on Sep 17, 2026

    @malibio
    CollaboratorAuthor

    Baseline (fresh worktree): Frontend 5152-5153 passed / 5154. The only failures are in src/tests/performance/architecture-benchmarks.test.ts and are flaky timing thresholds — two consecutive runs failed different benchmarks (combineNodes <40ms, then render-scales-linearly), so they are machine-speed sensitive, not regressions. No priority/query-service tests fail at baseline.

  2. self-assigned this
    on Sep 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions