PM-6007 - fix phase ordering when creating challenge - #155
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
This PR improves challenge creation phase scheduling by removing reliance on database row order and instead scheduling phases according to their predecessor relationships, while preventing “unscheduled” phases from accidentally being scheduled at the current time.
Changes:
- Added
orderPhasesByPredecessorChainto order timeline template phases so predecessors are processed before dependents. - Updated
populatePhasesForChallengeCreationto schedule using the ordered template and to leave phases unscheduled when their predecessor chain can’t be resolved. - Added unit tests covering unordered template rows and dangling predecessor chains.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
src/common/phase-helper.ts |
Adds dependency-based template ordering and updates creation-time scheduling to skip unresolved predecessors. |
test/unit/phase-helper.test.js |
Adds unit tests verifying correct scheduling with unordered template rows and missing-root predecessor chains. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
kkartunov
approved these changes
Aug 28, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request improves the scheduling logic for challenge phases by ensuring phases are ordered and scheduled according to their predecessor relationships, regardless of the order in which they are returned from the database. It introduces a utility to order phases by dependency and updates the scheduling logic to handle missing or cyclic dependencies more robustly. Comprehensive unit tests are also added to verify the new behavior.
Phase ordering and scheduling improvements:
orderPhasesByPredecessorChainutility to sort timeline template phases so each phase follows its predecessor, ensuring correct scheduling even when database rows are unordered. Phases with unresolved or cyclic dependencies are appended last, maintaining their relative order.ChallengePhaseHelper.populatePhasesForChallengeCreationto use the ordered template for phase scheduling, preventing reliance on database row order.Testing enhancements: