Skip to content

Expand core task.priority to a 5-level scale (closes #2651) - #2687

Merged
malibio merged 2 commits into
mainfrom
issue-2651-priority-5-level
Sep 17, 2026
Merged

malibio merged 2 commits into
mainfrom
issue-2651-priority-5-level

Conversation

@malibio

@malibio malibio commented Sep 17, 2026

Copy link
Copy Markdown
Collaborator

Closes #2651.

Replaces task.priority's 3-level core_values (low/medium/high) with the 5-level Highest/High/Medium/Low/Lowest scale, declared most- to least-urgent. The medium/high/low value strings are reused directly for continuity of meaning rather than renamed. Per the pre-release policy this is a straight replacement — no migration, no backfill.

Beyond the issue's stated scope

The issue described this as a one-field edit in core_schemas.rs. It isn't — the vocabulary is hardcoded in several more places, and two of them would have caused silent, non-obvious breakage:

  • Two independent TaskPriority enums — packages/core/src/models/task_node.rs and packages/nodespace-types/src/task.rs each enumerate the three variants in their FromStr/as_str impls, with a User(String) catch-all. Left alone, "highest" and "lowest" would parse to TaskPriority::User(_): they'd validate and round-trip fine, but report is_core() == false — silently treated as user extensions of the very field that declares them as core. Both enums are widened.
  • No drift test existed for priority. There is an ADR-076 bidirectional check asserting TaskStatus variants and task.status's core_values stay in sync, but no priority equivalent — which is precisely why this drift was easy to miss. Added test_task_priority_variants_match_core_values_bidirectionally as its sibling, so the next change to either side fails loudly.

Other call sites updated: the TS CoreTaskPriority union and its isCorePriority/getPriorityDisplayName helpers, the priority icon map in base-node-decoration.ts (highest/lowest previously rendered no icon at all), the LLM-facing vocabulary line in packages/skill/SKILL.md, and the schema fixtures/assertions that mirror the seed.

Deliberately left alone

  • project.priority (core_schemas.rs) is a separate field with the identical 3 values. The issue scopes this to task.priority and calls project-level changes a non-goal, so it is untouched — worth a follow-up decision.
  • Stale "legacy integer priority" comments in behaviors/mod.rs (1 = high, 2 = medium, 3-4 = low) describe a conversion that no longer exists in code; the test passes only because validation is permissive about the value type. Pre-existing, unrelated to this change, so not touched beyond not propagating the claim.
  • Priority sorting is plain lexicographic on the string, so 5 values sort as high < highest < low < lowest < medium. That was already nonsense ordering with 3 values (high < low < medium); no rank map exists to fix, and creating one is out of scope here.

Docs

../nodespace-docs/components/node-types.md schema reference updated and pushed straight to main (commit f33e723), per that repo's workflow.

Testing

  • Frontend: 247 files / 5085 tests passed — identical to the pre-change baseline.
  • Rust: full workspace builds; nodespace-core + nodespace-types suites green, including the new drift test.
  • bun run quality:fix clean (svelte-check 0 errors/0 warnings; clippy with -D warnings).
  • Full pre-push gate (test:all + cargo build --bin nodespaced + test:e2e) passed on push.

🤖 Generated with Claude Code

Replace task.priority's 3-level core_values (low/medium/high) with the
5-level Highest/High/Medium/Low/Lowest scale, ordered most- to
least-urgent. Existing value strings are reused for continuity of
meaning; per the pre-release policy this is a straight replacement with
no migration.

The schema seed is not the only place the vocabulary is hardcoded. Two
independent TaskPriority enums (packages/core and packages/nodespace-types)
enumerate the three variants in their FromStr/as_str impls; without
widening both, "highest" and "lowest" would parse to TaskPriority::User(_)
— validating fine while reporting is_core() == false, i.e. silently
treated as user extensions of the very field that declares them.

Also adds test_task_priority_variants_match_core_values_bidirectionally,
the priority sibling of the existing ADR-076 status drift check, which
asserts the enum and the schema seed stay consistent in both directions.
A check existed for task.status but not for task.priority, which is what
allowed this drift to go unnoticed.

Other call sites updated: the TS CoreTaskPriority union and its
isCorePriority/getPriorityDisplayName helpers, the priority icon map in
base-node-decoration (highest/lowest previously rendered no icon), the
LLM-facing vocabulary in packages/skill/SKILL.md, and the schema fixtures
and assertions that mirror the seed.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
@malibio

malibio commented Sep 17, 2026

Copy link
Copy Markdown
Collaborator Author

Code Review — PR #2687: Expand core task.priority to a 5-level scale

Initial Review · Verdict: Approve with minor follow-ups (self-authored PR, so posted as a comment — GitHub rejects --approve on your own PR).

Summary

This is a clear net positive and should merge. The issue framed the work as a one-field edit in core_schemas.rs; the author correctly discovered it was not, and the two enum widenings found along the way (packages/core/src/models/task_node.rs, packages/nodespace-types/src/task.rs) are the substantive part of the change. Without them "highest"/"lowest" would have parsed to TaskPriority::User(_) — validating and round-tripping cleanly while reporting is_core() == false, i.e. silently classified as user extensions of the very field that declares them as core. That is precisely the class of bug that costs a day to find later, and catching it unprompted is the best thing about this PR.

I verified the correctness claims rather than taking them on trust:

  • Symmetry of both enum copies — checked FromStr, as_str, #[default], Serialize, Deserialize in both. Both are complete and mutually consistent; Medium remains #[default] in both and stays a valid member of the new scale, so TaskNodeBehavior::default_metadata's "priority": "medium" seed (behaviors/mod.rs:722) is still correct. Serialization is serialize_str(self.as_str()) and deserialization is from_str(...).unwrap() on both sides, so round-tripping is exact for all five values. No asymmetry found.
  • The new drift test genuinely works. I mutation-tested it in both directions rather than reading it. Deleting "lowest" => Ok(Self::Lowest) from the enum → fails with the schema→enum message. Deleting the lowest EnumValue from the seed → fails with the enum→schema message. It is not a tautology, and it does assert what its doc comment claims.
  • Wire path is vocabulary-agnostic, as it should be: commands/nodes.rs:896 and daemon/src/services/node_service.rs:2613 both just pass as_str() / from_str through, so no third place needed updating.
  • The priority picker needed no change — task-schema-form.svelte:307-313 renders via SchemaFieldLeaf from the schema's own core_values, so it picks up all five values automatically. The issue's "frontend priority picker" acceptance criterion is satisfied by design, not by omission.
  • cargo clippy -p nodespace-core -p nodespace-types --all-targets -- -D warnings clean; targeted Rust and frontend suites green (134 frontend tests across the three touched files); nodespace-docs commit f33e723 confirmed present with the updated row at components/node-types.md:196.
  • Standards: no lint suppression, no any, no console.log, no #[allow(dead_code)], no #[deprecated], no docs added to this repo. The src-tauri/resources/skill/SKILL.md copy that also shows the new text is gitignored build output from build:skill, not an untracked source edit.

Absence of a data migration is correct per the repo's pre-release policy, not a defect.

The findings below are all non-blocking. Two of them are real gaps worth a quick follow-up commit; the rest is triage of the three deferred items.


Findings

Suggested Improvements

1. The new drift test guards only one of the two TaskPriority copies — the wrong one for the failure mode described. packages/core/src/models/core_schemas.rs:1891

The test imports crate::models::TaskPriority — the packages/core copy. The packages/nodespace-types copy is what actually serializes onto the frontend wire (TaskNode.priority in task.rs:112-135, via convert.rs:129), and nothing guards it.

I confirmed this empirically: deleting Lowest entirely from packages/nodespace-types/src/task.rs (variant, FromStr arm, as_str arm) leaves the whole suite green — all 60 nodespace-types tests pass and the new drift test passes. A future contributor adding a sixth priority to core_schemas.rs + packages/core gets a clean run while the wire type silently degrades "critical" to User(_).

This PR did the right thing manually for both copies. The value of the new test is that it makes the next change safe — and for the copy most likely to be forgotten, it currently doesn't. Since nodespace-types can't depend on nodespace-core, the cheap version is a self-contained test in packages/nodespace-types/src/task.rs asserting each of the five literals parses to a named (non-User) variant and round-trips through as_str:

#[test]
fn core_priority_literals_round_trip_to_named_variants() {
    for s in ["highest", "high", "medium", "low", "lowest"] {
        let p: TaskPriority = s.parse().unwrap();
        assert!(!matches!(p, TaskPriority::User(_)), "'{s}' fell through to User(_)");
        assert_eq!(p.as_str(), s);
    }
}

Principle: a regression test should cover the seam most likely to drift, and duplicated vocabulary across a crate boundary is exactly that seam. (Note TaskPriority in nodespace-types also has no is_core(), unlike the packages/core copy — hence the matches! form above.)

2. A stale priority proptest strategy was missed in convert.rs. packages/nodespace-types/src/convert.rs:521-527

/// Arbitrary task `priority` string (core and user-defined values).
fn task_priority() -> impl Strategy<Value = String> {
    prop_oneof![
        Just("low".to_string()),
        Just("medium".to_string()),
        Just("high".to_string()),
        "[a-z][a-z_]{0,15}".prop_map(|s| s),
    ]
}

The PR correctly updated the structurally identical strategy in packages/core/src/models/task_node.rs:906 (roundtrip_proptests::task_priority) to all five variants, but this sibling — which feeds the node_to_typed_value wire-conversion round-trip property — still enumerates only the old three. It isn't wrong (the free-form [a-z]{...} arm means highest/lowest are reachable by chance), but it no longer states the core vocabulary it claims to, and the round-trip property is now materially under-weighted on the two new values. Add highest and lowest. Together with finding 1, this is the same root cause: nodespace-types was updated in the source but not in its tests.

3. behaviors/mod.rs's "legacy integer priority" block is worse than stale — it's contradictory dead code. packages/core/src/behaviors/mod.rs:696-703, tests at 3189-3196

You flagged the comments as out of scope, which is defensible on its own. But the code beneath them is a stronger case than the PR body suggests:

// Validate priority type (must be integer if present)
if let Some(priority) = props.get("priority") {
    if !priority.is_i64() && !priority.is_null() {
        return Err(NodeValidationError::InvalidProperties(
            "Priority must be an integer".to_string(),
        ));
    }
}

This rejects exactly the string values the field is now defined in terms of. It is unreachable — it sits in the Err arm of TaskNode::from_node(...), and from_node (task_node.rs:391-397) only ever errors on node_type != "task", which TaskNodeBehavior::validate cannot see. So it is dead, and it's dead code whose comment block ("BACKWARD COMPATIBILITY: Accept both formats during transition", "old format, deprecated, will be auto-migrated") directly contradicts the CLAUDE.md pre-release policy.

I agree it's out of scope for this PR — deleting it means removing the fallback branch and its three tests, which is its own change with its own blast radius. But "stale comments" undersells it: this is a dead fallback that would reject valid priorities if it ever became reachable. Worth a follow-up issue rather than a note in a PR body, so it doesn't get rediscovered a third time.

4. Lexicographic priority sorting: correct to defer, but the PR does make the trap more convincing. packages/core/tests/query_service_test.rs:264-273, query_service_test.rs:1509

Your assessment that "no rank map exists" is accurate, and building one is genuinely out of scope. Three things are worth recording, though, because sorting by priority is a real user-reachable capability (OrderBy/SortConfig accepts priority, mapped to json_extract(properties, '$.task.priority')), not a theoretical one:

  • Old ascending order: high, low, medium. New: high, highest, low, lowest, medium.
  • The old ordering was obviously broken to anyone who looked. The new one is plausibly broken — high sorting adjacent to and just before highest, low before lowest, reads like it might be intentional, so a user is now less likely to notice the result is nonsense.
  • This PR's own text now asserts the ordering twice. The commit message says the scale is "ordered most- to least-urgent," and the rewritten field description at core_schemas.rs:128-131 says "Relative urgency for triage and sorting (highest, high, medium, low, lowest)". Nothing implements that order. The declaration is new prose in this diff, so while the broken sort is pre-existing, the claim that sorting works is partly introduced here.

Not a blocker and deferring the rank map is right. But since the description is being rewritten in this PR anyway, the cheapest honest fix is in scope: either drop "and sorting" from that sentence, or keep it and file the rank-map issue immediately so the claim has a dated owner. Leaving a fresh "for sorting" claim with no implementation is the part I'd push back on.

5. The two new icon branches ship untested. packages/desktop-app/src/lib/services/base-node-decoration.ts:229-234

base-node-decoration.test.ts:378-397 covers high → 🔴, low → 🔵, and the default → '', but there is no case for the newly added highest/lowest. These are the only two branches in the PR with genuinely new runtime behavior on the frontend (previously they rendered no icon at all), and they're the only ones with no assertion. Two lines in the existing 'should extract priority levels' block closes it.

6. named_variants in the drift test is hand-maintained, so the enum→schema direction has a hole. core_schemas.rs:1900-1906

I verified this: adding a new TaskPriority::Critical variant (with FromStr/as_str arms) but not adding it to the named_variants array leaves the test passing. The "every variant has a core_values entry" direction only checks the variants someone remembered to list.

This is inherited verbatim from the existing ADR-076 TaskStatus test, so it's a faithful mirror and not a defect this PR introduces — consistency with the established sibling is the right call here, and I'd rather not have the two tests diverge in structure. Flagging only so it's on record: if either test is ever hardened (e.g. via strum::EnumIter or a match on &self that won't compile when a variant is added), both should be done together.

Nitpicks

  • Nit: packages/desktop-app/src/lib/services/base-node-decoration.ts:219 — TaskNodeDecorator defaults to priority = 'normal' and status = 'pending'/'completed', a vocabulary that matches neither the old nor the new core scale and predates this PR. Harmless in context (these are content-parsed decoration hints, not stored properties) but it means the file now mixes two priority vocabularies within ~10 lines. Worth a comment noting they're deliberately distinct, if they are.
  • Nit: packages/desktop-app/src/lib/styles/noderef.css:310-316 — .ns-noderef--priority-high and .ns-noderef--priority-low are orphaned: nothing in the codebase applies either class (grepped .ts/.svelte/.css). Dead CSS that also encodes the 3-level assumption. Given CLAUDE.md's "delete unused code, don't suppress it" stance, deleting these two rules (and the now-unused --priority-low token) is a free cleanup — though equally fine to leave for a dedicated sweep.
  • Nit: core_schemas.rs:1884-1890 — the new test's doc comment is excellent, but unlike its TaskStatus sibling it doesn't reference ADR-076. Since it exists for the same standing reason, a /// ADR-076 standing check: opener would make the pairing greppable.

Deliberate scope calls I agree with

  • project.priority (core_schemas.rs:291-324) left at the old 3 values. Correct. The issue explicitly names project-level changes a non-goal, and it is a genuinely separate field on a separate schema with its own description text ("Relative importance for triage across projects"). Widening it opportunistically would have made this PR non-atomic. Two notes for the follow-up: the two fields are now visibly inconsistent for the same concept, which is a design question (should they share a scale?) rather than a code question; and unlike task.priority there is no ProjectPriority enum and no drift test of any kind guarding it, so whichever way that decision goes, nothing will flag it. Its fixture at generic-schema-form-project.test.ts:88-91 mirrors the 3 values and would need updating in lockstep. File it so the inconsistency is a decision rather than an accident.
  • No data migration. Correct per CLAUDE.md. Not a defect.

Verdict

Approve. The core change is correct, symmetric across both enum copies, verified by a drift test I confirmed actually fails on drift in both directions, and the discovery of the User(_) silent-misclassification trap is real engineering value beyond the issue's ask. Findings 1 and 2 (unguarded nodespace-types copy, stale proptest strategy) are worth a short follow-up commit before or shortly after merge — they're the difference between "fixed today" and "stays fixed." Findings 3, 4 and 6 are follow-up issues, not merge blockers. Nothing here should hold the PR.

@malibio malibio left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Initial Review complete — verdict: Approve (posted as a comment; GitHub rejects --approve on a self-authored PR).

Full report: #2687 (comment)

The core change is correct and symmetric across both TaskPriority copies, and I mutation-tested the new drift check — it genuinely fails in both directions. Catching the TaskPriority::User(_) silent-misclassification trap unprompted is real value beyond the issue's ask.

Non-blocking follow-ups worth a short commit:

  1. The new drift test guards only the packages/core copy — deleting Lowest from nodespace-types leaves the entire suite green (verified).
  2. packages/nodespace-types/src/convert.rs:521-527 — priority proptest strategy still enumerates only the old 3 values; its sibling in task_node.rs was updated.
  3. The rewritten field description newly claims the scale is "for triage and sorting," but sorting is still lexicographic with no rank map.

Nothing here should hold the merge.

The core-side bidirectional drift test added earlier only guards the
packages/core TaskPriority copy. The packages/nodespace-types copy is
what actually serializes onto the frontend wire, and nothing linked it
to either the schema seed or the core enum. Verified by mutation:
deleting Lowest from nodespace-types left all 60 tests green, so a
future sixth priority value could reach the frontend as
TaskPriority::User(_) with a fully passing suite.

Since nodespace-types cannot depend on nodespace-core, the guard is a
self-contained test pinning the five core literals to named variants
and asserting each round-trips through as_str(). Re-verified by
mutation: removing Lowest now fails that test.

Also:
- Widen the stale priority proptest strategy in convert.rs, which still
  generated only the old three values (same root cause — nodespace-types
  source was updated but its tests were not).
- Cover the new highest/lowest icon branches in base-node-decoration,
  the only genuinely new frontend runtime behavior in this PR.
- Drop "and sorting" from task.priority's schema description. Nothing
  implements rank ordering; sorting is lexicographic, so the claim was
  inaccurate the moment it was written. Filed as #2692.
- Delete the orphaned .ns-noderef--priority-high/low CSS rules (zero
  producers, and they encoded the 3-level assumption).
- Reference ADR-076 in the new drift test's doc comment so it greps
  alongside its TaskStatus sibling.

Deferred to follow-up issues rather than widening this PR:
#2692 (lexicographic priority sorting), #2693 (unreachable
integer-priority validation and phantom legacy-conversion comments),
#2694 (whether project.priority should match the 5-level scale).

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
@malibio

malibio commented Sep 17, 2026

Copy link
Copy Markdown
Collaborator Author

Review feedback addressed — commit f1c1ffd2

Thanks for the review, and in particular for mutation-testing the drift test rather than reading it. Finding 1 was correct and is the substantive fix here.

✅ Addressed (6)

1. Wire-type copy was unguarded — confirmed independently before fixing. Deleting Lowest from packages/nodespace-types/src/task.rs left all 60 tests green, including the new core-side drift test. Added a self-contained guard in that crate (it can't depend on nodespace-core) pinning the five core literals to named variants and asserting each round-trips through as_str(). Re-verified by mutation: removing Lowest now fails it. This was the right catch — the guarded copy was the one that mattered least.

2. Stale proptest in convert.rs — widened to the 5-level scale. Same root cause as finding 1: nodespace-types source updated, its tests not.

4. "and sorting" in the schema description — removed. You're right that this was a claim I newly introduced while nothing implements rank ordering; fixing the wording was cheaper and more honest than leaving it. Rank-map work filed as #2692.

5. Untested icon branches — added coverage for highest/lowest in base-node-decoration.test.ts.

Nit: orphaned CSS — deleted .ns-noderef--priority-high/low (zero producers, encoded the 3-level assumption). The --priority-high token is still referenced elsewhere in the file, so only the two orphaned rules went.

Nit: ADR-076 reference — added to the new test's doc comment so it greps alongside its TaskStatus sibling.

📋 Deferred to follow-up issues (3)

⏭️ Not changed (1)

6. Hand-maintained named_variants list — leaving as-is. You identified it's inherited verbatim from the existing ADR-076 TaskStatus test, and consistency with the sibling is worth more than unilaterally hardening one of the pair. If revisited, both should change together.

Nit: priority='normal' decorator default — pre-existing, and it parses content hints (Priority: high in text) rather than stored properties, so it's a different code path from the schema vocabulary. Out of scope here.

Verification

  • Frontend: 247 files / 5086 tests (up 1 from the new icon test), all passing
  • Rust: nodespace-types 61 tests (up 1 from the new guard), nodespace-core green
  • bun run quality:fix clean — svelte-check 0 errors / 0 warnings, clippy -D warnings
  • Full pre-push gate passed

@malibio
malibio merged commit 6a1e131 into main Sep 17, 2026
@malibio
malibio deleted the issue-2651-priority-5-level branch September 17, 2026 08:13
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.

Expand core task.priority to a 5-level scale (Highest/High/Medium/Low/Lowest)

1 participant