Skip to content

WL-0MP14WFW6001VE3G: Add priority normalization to create, update and doctor commands#2004

Merged
SorraTheOrc merged 1 commit into
mainfrom
feature/WL-0MP14WFW6001VE3G-priority-normalization
May 22, 2026
Merged

WL-0MP14WFW6001VE3G: Add priority normalization to create, update and doctor commands#2004
SorraTheOrc merged 1 commit into
mainfrom
feature/WL-0MP14WFW6001VE3G-priority-normalization

Conversation

@SorraTheOrc

Copy link
Copy Markdown
Member

Summary

Add priority normalization and validation across wl create, wl update, and wl doctor commands. This ensures consistent priority values in the database by normalizing case and providing a mapping for P* legacy values.

Work Done

  1. Created src/validators/priority.ts — a centralized priority validation/normalization utility with:

    • normalizePriority(raw) — case-normalizes canonical values, maps P0-P3 to canonical, returns null for unknown tokens
    • isValidPriority(raw) — checks if a value is a canonical priority (case-insensitive)
    • isMappablePriority(raw) — checks if a value is P0-P3 (case-insensitive)
    • Constants: CANONICAL_PRIORITIES and PRIORITY_MAP
  2. Updated wl create — validates the --priority flag: normalizes case, rejects P* and unknown tokens with a clear error message

  3. Updated wl update — validates the --priority flag with the same behavior as create

  4. Updated wl doctor:

    • New doctor priority subcommand with --dry-run (preview) and --apply (fix P* values)
    • Priority validation integrated into main doctor findings (reported with other findings)
    • doctor --fix applies the P*→canonical mapping for invalid priorities automatically
  5. Tests:

    • 14 unit tests covering src/validators/priority.ts
    • 6 integration tests covering doctor priority subcommand

How to Test

  • wl create -t "test" -p High — should work (normalizes to "high")
  • wl create -t "test" -p P1 — should fail with error about P* not accepted at creation
  • wl create -t "test" -p invalid — should fail with error
  • wl doctor priority --dry-run — preview invalid priorities
  • wl doctor priority --apply — fix P* values in the database

Review Focus

  • The validator logic in src/validators/priority.ts
  • Error messages in create.ts and update.ts for invalid priorities
  • The doctor priority subcommand and its JSON output format
  • Integration with the main doctor --fix flow

… doctor commands

- Create src/validators/priority.ts with normalizePriority, isValidPriority, isMappablePriority
- Update create.ts to validate and normalize priority on creation, rejecting P* values
- Update update.ts to validate and normalize priority on update, rejecting P* values
- Update doctor.ts with:
  - 'doctor priority' subcommand supporting --dry-run and --apply
  - Priority validation integrated into main doctor findings with --fix support
- Add unit tests for priority validator (14 tests)
- Add integration tests for doctor priority subcommand (6 tests)
@SorraTheOrc SorraTheOrc merged commit ad98232 into main May 22, 2026
4 of 5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant