Uh oh!
There was an error while loading. Please reload this page.
Refactor: Align Automated Labeling System with Project Specification and Enforce Type Labels - #110
Conversation
This commit refactors the automated labeling system to align with project specifications and fixes several critical bugs. ## Critical Fixes - **Fix changelog label detection**: Updated to check canonical labels (meta:needs-changelog, meta:no-changelog, meta:changelog) instead of non-existent legacy labels (no-changelog, changelog:added, etc.) - **Add type:* enforcement**: Extended one-hot enforcement to include type labels, ensuring exactly one type:* label per issue/PR - **Fix DRY_RUN default**: Changed default from "true" to "false" so labels are applied by default in production ## New Features - **Default type assignment**: Issues get type:task and PRs get type:chore as fallbacks when no type label exists - **Enhanced function naming**: Renamed enforceOneHotStatus to enforceOneHotLabels for clarity (backward compatible alias maintained) ## Code Quality - Updated all logging prefixes from [status-enforcer] to [label-enforcer] - Added comprehensive test coverage for all new functionality - Maintained backward compatibility with existing code ## Documentation - Added comprehensive gap analysis report - Created detailed changelog with migration guide - Documented all breaking changes and rollback procedures ## Files Changed - .github/agents/labeling.agent.js - .github/agents/includes/status-enforcer.js - .github/agents/includes/__tests__/status-enforcer.test.js - .github/workflows/labeling.yml - .github/reports/labeling-refactor-analysis.md (new) - .github/reports/labeling-refactor-changelog.md (new) ## Testing - All existing tests updated and passing - 7 new tests added for applyDefaultType - Backward compatibility test added - Integration tests updated to include type assignment ## References - Label Automation Strategy v1.1 - Labeling Agent Spec v2.0 - Label Strategy Documentation Closes issues related to automated labeling inconsistencies and brings the system into full compliance with project specifications.
Note
|
| Cohort / File(s) | Change Summary |
|---|---|
Status/Label Enforcer Core.github/agents/includes/status-enforcer.js, .github/agents/includes/__tests__/status-enforcer.test.js | Renamed enforceOneHotStatus to enforceOneHotLabels while maintaining backward-compatible alias. Added new public function applyDefaultType for applying default type labels. Updated module exports to expose both new names and aliases. Updated log prefixes from [status-enforcer] to [label-enforcer]. Tests now exercise enforceOneHotLabels as primary function with dedicated backward-compatibility test for alias. |
Labeling Agent.github/agents/labeling.agent.js | Updated function call from enforceOneHotStatus to enforceOneHotLabels. Added invocation of new applyDefaultType function after applyDefaultPriority step. Replaced changelog label set from previous naming to new meta-prefixed labels (meta:no-changelog, meta:needs-changelog, meta:changelog) with automatic addition of meta:needs-changelog when absent. |
Workflow Configuration.github/workflows/labeling.yml | Changed default value of DRY_RUN environment variable from 'true' to 'false', altering default behavior from dry-run to production labeling when inputs.dry_run is not provided. |
Documentation.github/reports/labeling-refactor-analysis.md, .github/reports/labeling-refactor-changelog.md | Added gap analysis document detailing critical issues, missing enforcement rules, and recommended refactoring priorities. Added changelog document documenting Version 2.0.0 release including breaking changes, new features, migration guide, and rollback plan. |
Sequence Diagram(s)
sequenceDiagram
participant Agent as Labeling Agent
participant Enforcer as Status-Enforcer Module
participant GitHub as GitHub API
Agent->>Enforcer: enforceOneHotLabels()
Enforcer->>GitHub: Remove conflicting one-hot labels
GitHub-->>Enforcer: Success
Agent->>Enforcer: applyDefaultStatus()
Enforcer->>GitHub: Add default status label
GitHub-->>Enforcer: Success
Agent->>Enforcer: applyDefaultPriority()
Enforcer->>GitHub: Add default priority label
GitHub-->>Enforcer: Success
Agent->>Enforcer: applyDefaultType()
Enforcer->>GitHub: Add default type label (new)
GitHub-->>Enforcer: Success
rect rgb(200, 220, 240)
Note over Agent: Backward Compatibility
Agent->>Enforcer: enforceOneHotStatus() [alias]
Enforcer->>Enforcer: → enforceOneHotLabels()
end
Estimated code review effort
🎯 3 (Moderate) | ⏱️ ~25 minutes
- Changelog label logic update: Verify the transition from old changelog labels to meta-prefixed naming and automatic
meta:needs-changelogaddition logic - DRY_RUN default change: Confirm implications of switching from dry-run to production mode by default and validate conditional logic in workflow
- Backward compatibility: Ensure the alias mechanism for
enforceOneHotStatusis properly tested and maintains full functional equivalence - New applyDefaultType implementation: Review logic for type label application, dry-run handling, and edge cases (PR vs. issue distinction)
Suggested labels
status:needs-review, lang:javascript, js, test, documentation
Suggested reviewers
- krugazul
Pre-merge checks and finishing touches
✅ Passed checks (3 passed)
| Check name | Status | Explanation |
|---|---|---|
| Title check | ✅ Passed | The title clearly describes the main refactoring effort: aligning the automated labeling system with project specs and enforcing type labels, which aligns with the comprehensive changes across labeling logic, new functions, and documentation. |
| Description check | ✅ Passed | The description follows the template structure with all critical sections completed: linked issues, changelog (Added/Changed/Fixed/Removed), risk assessment with details, comprehensive testing instructions with prerequisites and edge cases, and completed checklist items. All required information is present and well-organized. |
| Docstring Coverage | ✅ Passed | No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. |
✨ Finishing touches
- 📝 Generate docstrings
🧪 Generate unit tests (beta)
- Create PR with unit tests
- Post copyable unit tests in a comment
- Commit unit tests in branch
claude/refactor-automated-labeling-017WcicRHMspzWnu2WP6Ex9T
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Comment @coderabbitai help to get the list of available commands and usage tips.
Please check the workflow logs for details and ensure all frontmatter follows the schema at See Frontmatter Documentation for guidance. |
There was a problem hiding this comment.
Pull Request Overview
This PR refactors the automated labeling system to fix critical bugs and align with project specifications. Key changes include fixing changelog label detection to use canonical labels instead of non-existent legacy ones, extending one-hot enforcement to include type labels, and changing the DRY_RUN default to false so labels are applied in production.
Key Changes:
- Fixed changelog label detection using canonical labels (meta:needs-changelog, meta:no-changelog, meta:changelog)
- Added type:* label enforcement and default type assignment (type:task for issues, type:chore for PRs)
- Changed DRY_RUN workflow default from "true" to "false"
Reviewed Changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
.github/workflows/labeling.yml | Changed DRY_RUN default to false for production label application |
.github/reports/labeling-refactor-changelog.md | Comprehensive changelog documenting all changes, breaking changes, and migration guide |
.github/reports/labeling-refactor-analysis.md | Gap analysis report identifying issues and refactor plan |
.github/agents/labeling.agent.js | Updated changelog labels, added default type assignment, renamed function to enforceOneHotLabels |
.github/agents/includes/status-enforcer.js | Renamed enforceOneHotStatus to enforceOneHotLabels, added applyDefaultType function, updated logging prefixes |
.github/agents/includes/__tests__/status-enforcer.test.js | Added 7 new tests for applyDefaultType, updated existing tests for new function names |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…cRHMspzWnu2WP6Ex9T Signed-off-by: Ash Shaw <ashley@lightspeedwp.agency>
Please check the workflow logs for details and ensure all frontmatter follows the schema at See Frontmatter Documentation for guidance. |
There was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
.github/agents/labeling.agent.js (1)
15-35: Critical: Fix module import syntax errors.The file mixes ES modules (import/export) with CommonJS (require) incorrectly, and has duplicate/incomplete import statements:
- Lines 15-25: Use
require()in an ES module file- Lines 27-32: Duplicate the same imports using
importsyntax- Line 27: Incomplete destructuring statement
} from './includes/label-lookup.js';- Line 18: Biome parser error confirms syntax issue
This will cause runtime errors.
Apply this diff to fix the imports:
-import {- buildLabelAliasMap,- findStandardLabel,-} = require('./includes/label-lookup');-const {- enforceOneHotLabels,- enforceOneHotStatus, // backward compatibility- applyDefaultStatus,- applyDefaultPriority,- applyDefaultType,-} = require('./includes/status-enforcer');-const {-} from './includes/label-lookup.js';-import {- enforceOneHotStatus,- applyDefaultStatus,- applyDefaultPriority,-} from './includes/status-enforcer.js';+import {+ buildLabelAliasMap,+ findStandardLabel,+} from './includes/label-lookup.js';+import {+ enforceOneHotLabels,+ enforceOneHotStatus, // backward compatibility+ applyDefaultStatus,+ applyDefaultPriority,+ applyDefaultType,+} from './includes/status-enforcer.js';
🧹 Nitpick comments (1)
.github/agents/includes/__tests__/status-enforcer.test.js (1)
6-6: Update documentation to reflect the current API.The docblock still references
enforceOneHotStatusas a primary function, but it's now a backward-compatibility alias. Update to listenforceOneHotLabelsas the primary function and addapplyDefaultTypeto the list.Apply this diff to update the documentation:
- * - Tests status enforcement functions: enforceOneHotStatus, applyDefaultStatus, applyDefaultPriority+ * - Tests status enforcement functions: enforceOneHotLabels, applyDefaultStatus, applyDefaultPriority, applyDefaultType+ * - Also tests backward-compatibility alias: enforceOneHotStatus
📜 Review details
Configuration used: Path: .coderabbit.yml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (6)
.github/agents/includes/__tests__/status-enforcer.test.js(18 hunks).github/agents/includes/status-enforcer.js(7 hunks).github/agents/labeling.agent.js(3 hunks).github/reports/labeling-refactor-analysis.md(1 hunks).github/reports/labeling-refactor-changelog.md(1 hunks).github/workflows/labeling.yml(1 hunks)
🧰 Additional context used
📓 Path-based instructions (3)
**/.github/workflows/*.yml
⚙️ CodeRabbit configuration file
**/.github/workflows/*.yml: Review .github workflows for CI/CD:
- Check for use of reusable workflow templates and matrix strategies.
- Validate secrets and environment variables are handled securely.
- Ensure jobs have clear names and steps are well-commented.
- Ensure workflows enforce linting, testing, and release policies.
- Validate required status checks for merges.
- Check for proper branch and path filters.
- Confirm workflows are documented, maintainable, and DRY.
- Check for agent capabilities, tool integration, and test coverage.
- Ensure agent files reference org-wide standards and indexes.
- Ensure workflows run markdownlint, test jobs, and security checks as required.
Files:
.github/workflows/labeling.yml
.github/agents/**
⚙️ CodeRabbit configuration file
.github/agents/**: Prefer concise, actionable reviews. Respect documented style precedence. Link suggested fixes.
Files:
.github/agents/includes/__tests__/status-enforcer.test.js.github/agents/labeling.agent.js.github/agents/includes/status-enforcer.js
.github/agents/*.agent.js
⚙️ CodeRabbit configuration file
.github/agents/*.agent.js: Review all JavaScript agent files:
- Must start with a valid shebang and detailed header (purpose, usage, author, date).
- Require comprehensive JSDoc for all functions/classes.
- Must have a corresponding Jest test file with:
- Coverage for all agent capabilities and error paths.
- Mocks for external dependencies.
- Tests for edge cases and failure scenarios.
- Linting and type-checking enabled.
- Ensure agent is referenced in the agent index and spec.
Files:
.github/agents/labeling.agent.js
🧬 Code graph analysis (3)
.github/agents/includes/__tests__/status-enforcer.test.js (2)
.github/agents/labeling.agent.js (1)
currentLabels(171-173).github/agents/includes/status-enforcer.js (1)
enforceOneHotStatus(101-101)
.github/agents/labeling.agent.js (2)
.github/agents/includes/__tests__/status-enforcer.test.js (1)
require(17-23).github/agents/__tests__/labeling.agent.test.js (2)
require(1-9)require(10-10)
.github/agents/includes/status-enforcer.js (1)
.github/agents/labeling.agent.js (4)
number(150-154)currentLabels(171-173)isPR(148-148)dryRun(144-144)
🪛 Biome (2.1.2)
.github/agents/labeling.agent.js
[error] 18-18: expected from but instead found =
Remove =
(parse)
🪛 GitHub Actions: Frontmatter Validation
.github/reports/labeling-refactor-analysis.md
[error] 1-1: Frontmatter validation failed: tag 'file_type' must be string.
🪛 LanguageTool
.github/reports/labeling-refactor-analysis.md
[uncategorized] ~14-~14: The official name of this software platform is spelled with a capital “H”.
Context: ...labeling specifications in /docs/ and /.github/agents/ and the current implementation...
(GITHUB)
[uncategorized] ~22-~22: The official name of this software platform is spelled with a capital “H”.
Context: ...Changelog Label Mismatch Location:.github/agents/labeling.agent.js (lines 194-21...
(GITHUB)
[uncategorized] ~34-~34: The official name of this software platform is spelled with a capital “H”.
Context: ...lete One-Hot Enforcement Location:.github/agents/labeling.agent.js (lines 166-17...
(GITHUB)
[uncategorized] ~46-~46: The official name of this software platform is spelled with a capital “H”.
Context: ... DRY_RUN Default Setting Location:.github/workflows/labeling.yml (line 88) **Is...
(GITHUB)
[uncategorized] ~99-~99: The official name of this software platform is spelled with a capital “H”.
Context: ...while the actual canonical file is at.github/automation/labels.yml`. Examples: ...
(GITHUB)
[uncategorized] ~109-~109: The official name of this software platform is spelled with a capital “H”.
Context: ...Missing report-writer.js Location:.github/workflows/labeling.yml (line 95) **Is...
(GITHUB)
[uncategorized] ~189-~189: The official name of this software platform is spelled with a capital “H”.
Context: ...y Discussion Label Rules Location:.github/automation/labeler.yml (lines 80-100) ...
(GITHUB)
.github/reports/labeling-refactor-changelog.md
[uncategorized] ~14-~14: The official name of this software platform is spelled with a capital “H”.
Context: ...ations in /docs/label-automation/ and /.github/agents/. All high-priority issues have...
(GITHUB)
[style] ~94-~94: ‘with success’ might be wordy. Consider a shorter alternative.
Context: ...erage:** All new functions fully tested with success, error, and edge cases --- ## Files C...
(EN_WORDINESS_PREMIUM_WITH_SUCCESS)
[uncategorized] ~191-~191: If this is a compound adjective that modifies the following noun, use a hyphen.
Context: ...No action required: All changes are backward compatible - Changelog labels: Use canonical l...
(EN_COMPOUND_ADJECTIVE_INTERNAL)
[grammar] ~251-~251: Ensure spelling is correct
Context: ... git push origin develop 2. **Temporary Disable** yaml # In .github/wo...
(QB_NEW_EN_ORTHOGRAPHY_ERROR_IDS_1)
🔇 Additional comments (15)
.github/agents/includes/__tests__/status-enforcer.test.js (6)
17-23: LGTM!The imports correctly include both the new primary function (
enforceOneHotLabels) and the backward-compatibility alias (enforceOneHotStatus), with clear inline documentation. The newapplyDefaultTypefunction is also properly imported.
92-103: LGTM!The backward-compatibility test appropriately verifies that the
enforceOneHotStatusalias continues to function correctly. While minimal, this is sufficient given the alias is a direct reference toenforceOneHotLabels.
55-253: LGTM!Comprehensive test coverage for
enforceOneHotLabelswith consistent usage throughout. Tests cover one-hot enforcement for status, priority, and type labels, along with edge cases (empty arrays, malformed labels, dry-run mode, error handling).
472-599: LGTM!Excellent test coverage for the new
applyDefaultTypefunction. The tests follow the established patterns fromapplyDefaultStatusandapplyDefaultPriority, verifying default behavior for both issues (type:task) and PRs (type:chore), error handling, dry-run mode, and compatibility with all type labels.
601-722: LGTM!Integration scenarios properly updated to include
applyDefaultTypein the complete workflow. The tests verify that new issues and PRs receive appropriate default type labels (type:taskfor issues,type:chorefor PRs) along with status and priority defaults.
724-797: LGTM!Error handling and edge case tests properly updated to use
enforceOneHotLabels. Good coverage includes network failures, malformed labels, and performance validation for large label lists..github/workflows/labeling.yml (1)
88-88: Verify the intentional inconsistency between automatic and manual trigger defaults.The change to
'false'means automatic triggers (push, pull_request, issues, discussion) will apply labels in production mode, while manualworkflow_dispatchtriggers still default to dry-run ('true'at line 18). This creates different default behaviors:
- Automatic events: labels applied (
DRY_RUN='false')- Manual dispatch: dry-run mode (
inputs.dry_run='true'→DRY_RUN='true')If this differentiation is intentional (safe manual testing, production automation), consider adding a comment explaining the rationale.
.github/reports/labeling-refactor-changelog.md (1)
1-312: Excellent comprehensive changelog documentation.This changelog is thorough, well-structured, and provides clear migration guidance. It effectively documents breaking changes, new features, bug fixes, testing coverage, and includes practical rollback procedures.
.github/agents/labeling.agent.js (2)
176-209: LGTM: Function calls correctly updated.The enforcement and default application logic is correctly implemented:
- Uses
enforceOneHotLabels(renamed function)- Adds
applyDefaultTypecall with appropriate parameters- Maintains proper execution order: enforce one-hot first, then apply defaults
213-217: Excellent: Changelog labels correctly updated to canonical set.The changelog label list now uses the correct
meta:*prefixed labels that exist in the canonical set, fixing the critical bug where changelog detection never worked properly..github/reports/labeling-refactor-analysis.md (1)
10-312: Excellent gap analysis with actionable recommendations.This analysis document effectively identifies critical issues, provides clear priorities, and includes a concrete implementation checklist. The issues documented align well with the fixes implemented in this PR.
.github/agents/includes/status-enforcer.js (4)
28-28: Excellent: Function renamed with backward compatibility maintained.The rename from
enforceOneHotStatustoenforceOneHotLabelsaccurately reflects that the function now enforces one-hot constraints for status, priority, AND type labels. The backward compatibility alias ensures existing code continues to work.Also applies to: 100-101
58-58: Logging prefix consistently updated.The logging prefix change from
[status-enforcer]to[label-enforcer]is consistent throughout and better reflects the module's expanded scope.Minor note: The filename
status-enforcer.jsnow has a slight mismatch with the[label-enforcer]logging prefix, but this is acceptable given backward compatibility requirements.Also applies to: 61-61, 74-74, 80-80, 86-86, 94-94
236-303: LGTM: New applyDefaultType function correctly implemented.The function follows the established pattern from
applyDefaultStatusandapplyDefaultPriority:
- Proper parameter validation
- Checks for existing
type:*labels- Applies sensible defaults (type:task for issues, type:chore for PRs)
- Consistent error handling and logging
- Comments explain that PR types should ideally come from labeler.yml first
305-311: Module exports correctly updated.The exports properly expose:
- New function name
enforceOneHotLabels- Backward-compatible alias
enforceOneHotStatus- New function
applyDefaultType- Existing functions
applyDefaultStatusandapplyDefaultPriorityThis maintains backward compatibility while exposing the new functionality.
| --- | ||
| title: 'Automated Labeling Refactor Analysis' | ||
| version: '1.0.0' | ||
| date: '2025-11-18' | ||
| author: 'Claude (Sonnet 4.5)' | ||
| status: 'draft' | ||
| tags: ['automation', 'labeling', 'analysis', 'refactor'] | ||
| --- |
There was a problem hiding this comment.
Fix frontmatter validation error: missing 'file_type' tag.
The pipeline validation failed because the frontmatter is missing a required file_type tag. Add it to match the validation schema.
Apply this diff to fix the frontmatter:
---
title: 'Automated Labeling Refactor Analysis'
version: '1.0.0'
date: '2025-11-18'
author: 'Claude (Sonnet 4.5)'
status: 'draft'
tags: ['automation', 'labeling', 'analysis', 'refactor']
+file_type: 'analysis'
---📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| --- | |
| title: 'Automated Labeling Refactor Analysis' | |
| version: '1.0.0' | |
| date: '2025-11-18' | |
| author: 'Claude (Sonnet 4.5)' | |
| status: 'draft' | |
| tags: ['automation', 'labeling', 'analysis', 'refactor'] | |
| --- | |
| --- | |
| title: 'Automated Labeling Refactor Analysis' | |
| version: '1.0.0' | |
| date: '2025-11-18' | |
| author: 'Claude (Sonnet 4.5)' | |
| status: 'draft' | |
| tags: ['automation', 'labeling', 'analysis', 'refactor'] | |
| file_type: 'analysis' | |
| --- |
🧰 Tools
🪛 GitHub Actions: Frontmatter Validation
[error] 1-1: Frontmatter validation failed: tag 'file_type' must be string.
🤖 Prompt for AI Agents
.github/reports/labeling-refactor-analysis.md lines 1-8: the YAML frontmatter is
missing the required file_type tag which causes pipeline validation to fail; add
a file_type entry (for example file_type: 'report' or another schema-allowed
value) to the top-level frontmatter so the file conforms to the validation
schema and re-run the pipeline.
Uh oh!
There was an error while loading. Please reload this page.
name: "Pull Request"
about: "General changes, refactors, and maintenance"
title: "Refactor: Align Automated Labeling System with Project Specification and Enforce Type Labels"
labels: ["status:needs-review"]
General Pull Request
This PR comprehensively refactors the automated labeling system to fully comply with project specifications, introduces stricter type label enforcement, and resolves several critical issues impacting workflow automation.
Critical Fixes
meta:needs-changelog,meta:no-changelog,meta:changelog) instead of deprecated forms.type:*label per issue/PR; enforces automatic assignment:type:taskfor issues andtype:chorefor PRs if missing."true"to"false", so labeling is live by default in production.New Features
enforceOneHotStatustoenforceOneHotLabels(backward compatibility preserved via alias).[status-enforcer]log prefixes are now[label-enforcer]for clarity and tracing.Code Quality
applyDefaultType, enforcement logic).Documentation
Files Changed
.github/agents/labeling.agent.js.github/agents/includes/status-enforcer.js.github/agents/includes/__tests__/status-enforcer.test.js.github/workflows/labeling.yml.github/reports/labeling-refactor-analysis.md(new).github/reports/labeling-refactor-changelog.md(new)Testing
References
Closes issues related to automated labeling inconsistencies and achieves full alignment with current project labeling specs.
Linked issues
Closes #
Changelog
Added
type:task(issues) andtype:chore(PRs) if no type label present.labeling-refactor-analysis.mdandlabeling-refactor-changelog.mddocumentation reports.Changed
meta:needs-changelog,meta:no-changelog,meta:changelog).type:*labels.DRY_RUNnow defaults tofalse—live labeling enabled by default.[label-enforcer].enforceOneHotStatusrenamed toenforceOneHotLabels(alias kept).Fixed
Removed
no-changelog,changelog:added, etc.).Risk Assessment
Risk Level: Medium
Potential Impact:
Mitigation Steps:
How to Test
Prerequisites
type:*label.labeling.ymlis enabled for test branches.Test Steps
type:*label — should receivetype:task.type:*label — should receivetype:chore.type:*labels — PR/issue should keep only one.meta:needs-changelog, etc.) — only canonical forms are recognized.[label-enforcer]prefix..github/agents/includes/__tests__/status-enforcer.test.js— all must pass.reports/for migration and gap analysis.Expected Results
type:*label present per item.Edge Cases to Verify
DRY_RUN=true) safety still available for local/test.Checklist (Global DoD / PR)
References
Summary by CodeRabbit
New Features
Bug Fixes
Documentation