wire-priority-field

Priority as u32 (no upper bound) + gray display + sort dispatch by it

Metadata

Statusdone
Assignedagent-162
Agent identityf51439356729d112a6c404803d88015d5b44832c6c584c62b96732b63c2b0c7e
Created2026-04-26T16:04:34.006073006+00:00
Started2026-04-26T23:06:52.791643184+00:00
Completed2026-04-26T23:26:19.857922279+00:00
Tagseval-scheduled
Tokens11555731 in / 32840 out
Eval score0.16
└ blocking impact0.15
└ completeness0.05
└ coordination overhead0.40
└ correctness0.10
└ downstream usability0.30
└ efficiency0.10
└ intent fidelity0.52
└ style adherence0.20

Description

Description

Combined work: convert Priority from named enum to unbounded u32, restyle display to match muted-gray time markers, and (the original spec) honor priority in dispatch sort order.

A. Priority becomes u32 (replaces named enum)

User decision: Priority enum (Critical/High/Normal/Low/Idle) is too rigid — when you need to put something on top of a Critical, you're stuck. Switch to:

  • Type: u32. Low = 0. No upper bound.
  • Default: 10 (room to bump down to 0 or up to 100+).
  • CLI accepts both numeric (wg reprioritize foo 50) AND named aliases as input convenience (wg reprioritize foo high resolves to a configured numeric value, e.g. critical=100, high=50, normal=10, low=5, idle=0). Aliases are INPUT-ONLY.
  • Display ALWAYS shows the number ([10]), never the name. Don't double-display.
  • Migrate existing data: read old enum values from graph.jsonl, map to numeric (Critical→100, High→50, Normal→10, Low→5, Idle→0). Write as u32 going forward.

B. Display restyling

Currently priority badges render in purple (e.g., [35m[high][0m ANSI). User finds this too intense. Match the muted-gray color used for time-since-creation markers (e.g., 25m in wg viz output). Likely \033[90m (bright black / gray) or whatever color those time markers use — read from the same constant.

Apply consistently: wg list, wg viz, wg ready, wg show, TUI views — anywhere a priority badge appears.

C. Honor priority in dispatch (the original spec)

Sort ready tasks by priority (DESCENDING — higher number = dispatched first) before applying secondary sort by cost/hours. Currently src/query.rs:148 sorts by get_value only.

  • Higher u32 = higher priority. Tasks with priority 100 dispatch before priority 10.
  • Within same priority level: round-robin / fair share by tracked accumulated dispatch (CFS-like vruntime). Initial impl can just sort secondarily by cost/hours; the fair-share refinement can be follow-up if needed.
  • Idle priority (0) only dispatches if no priority-1+ task is ready AND there's spare max_agents slack.
  • High-priority preemption (kill lower-priority running agent for higher-priority pending) is OUT OF SCOPE — defer to v2.
  • Default priorities for system-spawned tasks: chat-loop tasks at 50; .assign / .evaluate / .flip at 10; user tasks at 10; explicit user override always wins.

Files likely to touch

  • src/graph.rs — Priority type def + Task field + serde migration from old enum strings
  • src/commands/reprioritize.rs — accept numeric + named aliases; emit number
  • src/commands/list.rs, src/commands/show.rs — display badge in gray
  • src/commands/viz/mod.rs — same
  • src/tui/viz_viewer/state.rs — TUI badge rendering
  • src/query.rs — dispatch sort by priority desc
  • src/commands/service/mod.rs and/or src/commands/service/coordinator.rs — wherever ready-task selection feeds dispatch

Migration

  • Old graph.jsonl entries with string-enum values ("high", "critical", etc.) must deserialize cleanly into u32 (apply the mapping). One-time migration on first read.
  • Once read, written as u32. Don't ship a flag day; the deserializer handles both for one release.

What to drop

  • The Priority enum definition (replace with type alias pub type Priority = u32 if needed for API stability, or remove entirely).
  • Any code that switches on enum variants — replace with numeric thresholds.

Validation

  • Failing tests first:
    • test_priority_is_u32 — Task.priority field is u32, default 10
    • test_priority_serde_migration_from_named_enum — old graph.jsonl with "high"/"critical" deserializes correctly
    • test_reprioritize_accepts_numeric_and_named — both wg reprioritize x 50 and wg reprioritize x high work; both store as u32
    • test_display_uses_gray_not_purple — badge ANSI is the muted-gray color (matches time-marker color), NOT \033[35m
    • test_dispatch_orders_by_priority_descending — priority 100 task dispatched before priority 10 task in the same ready set
    • test_idle_priority_zero_only_dispatched_when_higher_empty
  • Implementation makes tests pass
  • cargo build + cargo test pass with no regressions
  • Manual smoke:
    • In a scratch dir: 3 tasks at priorities 100, 10, 0 → service dispatches in that order with max_agents=1
    • Existing graph with old enum priorities loads cleanly, displays as numbers in muted gray
    • wg reprioritize foo high works; wg show foo displays priority as a number, not 'high'
    • Visual: wg viz priority badge color matches the time-since-creation color (subjectively muted, not bright purple)

Depends on

Required by

Messages 8 messages (8 unread)

  1. #1user2026-04-26T16:52:34.142447656+00:00delivered
    Spec amended (see updated description). Two folded-in changes:
    1. Priority becomes u32 (no upper bound), low=0, default=10. Drop the named enum. Accept named aliases as INPUT convenience only; always display as number.
    2. Display badge color: muted gray (matching the time-since-creation marker color, e.g. \\033[90m), NOT purple. Apply across wg list/viz/ready/show/TUI.
    3. Dispatch sort honors u32 priority descending, plus the existing secondary sort.
    Migration: old graph.jsonl with named-enum strings ("high", "critical", etc.) must deserialize cleanly via mapping (Critical→100, High→50, Normal→10, Low→5, Idle→0).
  2. #2user2026-04-26T16:53:04.515678982+00:00delivered
    Display addendum: priority badge symbol = ⚡ (lightning bolt). Placement: inside the (...) status region, at the END after § context counter, before the closing paren. Example: '(in-progress · →270k ←4.7k ◎21M §6.0k ⚡10)'. The number is the u32 priority. Color stays muted gray (matching time-since-creation color), not purple. Drop the standalone [high]/[10] badge that currently appears outside the parens — fold the info into the in-paren ⚡N glyph.
  3. #3user2026-04-26T16:53:24.552232789+00:00delivered
    Format clarification: use ' · ' (middle-dot separator, same as the one between status and token counts) BEFORE the ⚡ glyph to distinguish priority from the token-count cluster. Final format: '(in-progress · →270k ←4.7k ◎21M §6.0k · ⚡10)'. So the parens read as: status · counters · priority.
  4. #4user2026-04-26T16:55:04.011655840+00:00read
    Symbol correction: use ↯ (U+21AF, wg's existing WAVE_BOLT throbber char from src/tui/viz_viewer/render.rs:14) instead of ⚡. Reason: ⚡ is an emoji (triggers color rendering, looks harsh). ↯ is a plain text glyph with the same lightning semantic, renders consistently in monospace, matches the wg throbber aesthetic. Final format: '(in-progress · →270k ←4.7k ◎21M §6.0k · ↯10)'.
  5. #5user2026-04-26T16:56:47.113639993+00:00read
    Symbol + color final: use ▴ (U+25B4 BLACK UP-POINTING SMALL TRIANGLE) for the priority marker, NOT ↯ and NOT ⚡. Reason: 'up' reads as priority, ▴ is a clean small text glyph matching the existing small-unicode-marker aesthetic (→ ← ◎ § ✉), no emoji rendering. Color: DEFAULT terminal color, no ANSI styling. Drop both the purple AND the gray styling I previously specced. Final format: '(in-progress · →270k ←4.7k ◎21M §6.0k · ▴10)'.
  6. #6wire-priority-field2026-04-26T16:57:13.638439834+00:00read
    Acknowledged — will use ▴ (U+25B4) with default terminal color (no ANSI styling) for priority marker. Format: '(status · tokens · ▴N)'. Dropping both purple and gray styling.
  7. #7user2026-04-26T20:12:48.348742420+00:00delivered
    Final symbol decision: ⌁ (U+2301 ELECTRIC ARROW). NOT ⚡ (emoji), NOT ↯ (downwards zigzag), NOT ▴ (triangle). User picked ⌁ for the energy/lightning feel as a plain text glyph. Final format: '(in-progress · →270k ←4.7k ◎21M §6.0k · ⌁10)'. Default terminal color, dot separator before. This supersedes all 5 prior symbol messages.
  8. #8wire-priority-field2026-04-26T23:09:07.436351944+00:00read
    Acknowledged final symbol decision (⌁ U+2301 ELECTRIC ARROW). Prior agent-51 commit landed ▴ — will update all 5 display sites to ⌁ and adjust tests.

Log