@@ -29,14 +29,18 @@ const logger = {
2929} ;
3030
3131/**
32- * Determines the skill- level label applied to an issue/PR.
32+ * Determines the difficulty level of an issue/PR based on its labels .
3333 *
34- * Iterates through SKILL_HIERARCHY in ascending order and returns the
35- * first matching label found on the issue. This ensures consistent
36- * detection even if multiple labels are present (lower levels take precedence).
34+ * Strategy:
35+ * - Checks labels against SKILL_HIERARCHY in order
36+ * - Returns the first matching level (lowest takes precedence)
37+ *
38+ * Behavior:
39+ * - Returns matching LABELS constant if found
40+ * - Returns null if no difficulty label is present
3741 *
38- * @param {{ labels: Array<string|{ name: string }> } } issue - Issue or PR object from GitHub payload .
39- * @returns {string|null } Matching LABELS constant (e.g. LABELS.BEGINNER), or null if none found.
42+ * @param {{ labels: Array<string|{ name: string }> } } issue - Issue or PR object.
43+ * @returns {string|null } Detected difficulty level or null if none found.
4044 */
4145function getIssueSkillLevel ( issue ) {
4246 for ( const level of SKILL_HIERARCHY ) {
@@ -46,14 +50,19 @@ function getIssueSkillLevel(issue) {
4650}
4751
4852/**
49- * Computes the next recommended difficulty level based on progression.
53+ * Computes the next difficulty level for progression.
5054 *
5155 * Strategy:
5256 * - Move one level higher in SKILL_HIERARCHY
53- * - If already at highest level, return the same level (no upward progression possible)
57+ * - If already at highest level, return the same level
5458 *
55- * @param {string } currentLevel - Current skill-level label.
56- * @returns {string|null } Next level label, or null if currentLevel is invalid.
59+ * Behavior:
60+ * - Returns next level if available
61+ * - Returns same level if already at maximum
62+ * - Returns null if input is invalid
63+ *
64+ * @param {string } currentLevel
65+ * @returns {string|null }
5766 */
5867function getNextLevel ( currentLevel ) {
5968 const index = SKILL_HIERARCHY . indexOf ( currentLevel ) ;
@@ -67,10 +76,15 @@ function getNextLevel(currentLevel) {
6776 *
6877 * Strategy:
6978 * - Move one level lower in SKILL_HIERARCHY
70- * - Used as a last resort when both next-level and same-level issues are unavailable
79+ * - Used as a last resort when higher and same-level issues are unavailable
7180 *
72- * @param {string } currentLevel - Current skill-level label.
73- * @returns {string|null } Lower level label, or null if already at lowest level.
81+ * Behavior:
82+ * - Returns the previous level in the hierarchy
83+ * - Returns null if already at the lowest level
84+ * - Returns null if input level is invalid
85+ *
86+ * @param {string } currentLevel - Current difficulty level.
87+ * @returns {string|null } Fallback level or null if none exists.
7488 */
7589function getFallbackLevel ( currentLevel ) {
7690 const index = SKILL_HIERARCHY . indexOf ( currentLevel ) ;
@@ -80,24 +94,27 @@ function getFallbackLevel(currentLevel) {
8094}
8195
8296/**
83- * Fetches open, unassigned issues for a given difficulty level using GitHub search API.
97+ * Fetches open, unassigned issues for a given difficulty level using the GitHub search API.
8498 *
85- * Filters applied:
86- * - Only issues (no PRs)
87- * - Open state
88- * - No assignee (available to contributors)
89- * - Matching skill-level label
90- * - Must be "status: ready for dev"
99+ * Strategy:
100+ * - Query issues within the target repository
101+ * - Filter by:
102+ * - Open state
103+ * - No assignee
104+ * - Matching difficulty label
105+ * - "ready for dev" status label
106+ * - Limit results to a small, relevant set
91107 *
92- * Returns :
93- * - Array of issues if successful (possibly empty)
94- * - null if API call fails (caller must handle failure explicitly)
108+ * Behavior :
109+ * - Returns an array of issues (may be empty if none found )
110+ * - Returns null if the API request fails
95111 *
96112 * @param {object } github - Octokit GitHub API client.
97113 * @param {string } owner - Repository owner.
98114 * @param {string } repo - Repository name.
99- * @param {string } level - Skill-level label used for filtering.
100- * @returns {Promise<Array<{ title: string, html_url: string }>|null> } List of issues or null on failure.
115+ * @param {string } level - Difficulty level used for filtering.
116+ * @returns {Promise<Array<{ title: string, html_url: string }>|null> }
117+ * List of issues, [] if none found, or null on failure.
101118 */
102119async function fetchIssuesByLevel ( github , owner , repo , level ) {
103120 try {
@@ -140,7 +157,7 @@ async function fetchIssuesByLevel(github, owner, repo, level) {
140157 *
141158 * @param {object } botContext - Bot execution context (GitHub client, repo info, etc.).
142159 * @param {string } username - GitHub username to mention in error comment.
143- * @param {string } level - Skill-level label used for filtering.
160+ * @param {string } level - Difficulty label used for filtering.
144161 * @param {{ hasErrored: boolean } } errorState - Tracks whether error comment has been posted.
145162 *
146163 * @returns {Promise<Array<{ title: string, html_url: string }>|null> } List of issues, or null if API failed.
0 commit comments