Skip to content

Fix findNextWorkItem tie-break and in-progress boost tests (WL-0MN7GBSL41M52FTM)#1041

Merged
SorraTheOrc merged 3 commits intomainfrom
wl/WL-0MN7GBSL41M52FTM-tiebreak-fix
Mar 26, 2026
Merged

Fix findNextWorkItem tie-break and in-progress boost tests (WL-0MN7GBSL41M52FTM)#1041
SorraTheOrc merged 3 commits intomainfrom
wl/WL-0MN7GBSL41M52FTM-tiebreak-fix

Conversation

@SorraTheOrc
Copy link
Copy Markdown
Member

Summary

Reduced failing tests from 7 to 3. Fixes tie-breaking and in-progress boost handling in selectBySortIndex and computeScore.

Changes

  1. computeScore uses effective priority (not raw priority) for base score — children now correctly inherit parent priority for scoring.

  2. Blocked penalty only applies when item has active dependency edges — fixes "ignore blocking issues mentioned in description/comments" tests (items with status='blocked' but no active outgoing edges are treated as normal candidates).

  3. ancestorsOfInProgress passed to computeScore in selectBySortIndex tie-break — parent-in-progress boost now applies during tie-breaking.

  4. New computeBoost helper — separates boost calculation from base score for tie-breaking.

  5. selectBySortIndex tie-break order: effective priority → boost → createdAt → ID.

  6. in_review staged blocked items treated as non-blocking in computeScore.

Remaining Failures (design conflicts — 3 tests)

These tests encode incompatible design requirements:

  1. should preserve priority dominance (×2): Both items have effective priority 3 (itemB inherits from blocked dependent). Boost tie-break then selects itemB (boost 500). Test expects itemA (high, no boost) to win. This is a design conflict: boost correctly lets medium unblockers win over equal-priority peers, but also incorrectly lets medium+boost win over high when effective priorities are equal via inheritance.

  2. should not boost a blocked item: Blocked parent without active dependency edges ties with open item on effective priority and wins by createdAt. Test expects open item to win (requires -10000 penalty on ALL blocked items, which conflicts with the "ignore description/mentions" fix).

These 3 tests will fail until a design decision is made about priority inheritance and the blocked penalty scope.

Test Results

  • Before: 7 failures
  • After: 3 failures (all pre-existing or design conflicts)

References

  • WL-0MN7GBSL41M52FTM

@SorraTheOrc SorraTheOrc force-pushed the wl/WL-0MN7GBSL41M52FTM-tiebreak-fix branch from cfaaed5 to ea9176b Compare March 26, 2026 13:31
…SL41M52FTM)

Fix: Ensure priority dominance is preserved by using raw priority (not effective
priority) in the base score, so that high priority always dominates medium
regardless of inheritance or boosts.

The blocked penalty applies to ALL blocked items (original behavior, restored
per user request).

Tie-breaking in selectBySortIndex (effective priority → createdAt → ID)
preserves the original algorithm with cleaner comments.

Test pollution note: The priority dominance test passes in isolation but can
fail in the full suite due to pre-existing test isolation issues (not a
code bug).
@SorraTheOrc SorraTheOrc force-pushed the wl/WL-0MN7GBSL41M52FTM-tiebreak-fix branch from ea9176b to dcd03ce Compare March 26, 2026 13:39
Sorra the Orc added 2 commits March 26, 2026 14:53
…ests (WL-0MN7GBSL41M52FTM)

Root cause: When items were created at the same millisecond, they had
identical createdAt timestamps. The sort tie-breaker used ID comparison
via localeCompare, but the random component in IDs meant lexicographic
order didn't preserve creation order.

Fix: Added a sequence counter to ID generation. When multiple IDs are
generated within the same millisecond, the sequence number ensures
deterministic ordering that reflects creation order.

Changes:
- Added _lastIdTime and _idSequence fields to WorklogDatabase
- Modified generateUniqueId to use sequence counter
- Updated ID length constants to accommodate sequence (now 16 chars total)
- Added defensive JSONL refresh skip for TEST prefix databases

Test results: database.test.ts and next-regression.test.ts now pass
consistently (5/5 runs) where they previously had 0-2 failures per run.
The check was preventing CLI tests from importing work items from JSONL
files, causing export/import tests to fail with itemsCount=0.

The sequence counter fix in generateUniqueId already addresses the
test pollution issue, so this defensive check is no longer needed.
@SorraTheOrc SorraTheOrc merged commit 5224381 into main Mar 26, 2026
4 checks passed
@SorraTheOrc SorraTheOrc deleted the wl/WL-0MN7GBSL41M52FTM-tiebreak-fix branch March 27, 2026 23:05
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