Skip to content

feat(labels): scope org-label sync to a repo list; seed catalog labels on PR-apply - #266

Merged
Shinrai merged 5 commits into
nextfrom
feat/label-sync-scope-and-ensure
Sep 6, 2026
Merged

Shinrai merged 5 commits into
nextfrom
feat/label-sync-scope-and-ensure

Conversation

@cldmv-bot

@cldmv-bot cldmv-bot Bot commented Sep 3, 2026 •

Copy link
Copy Markdown
Contributor

🚀 What's Changed

💥 Breaking Changes

No breaking changes

✨ Features

🐛 Bug Fixes

📦 Dependencies

No dependency updates

🔧 Other Changes

No other changes

👥 Contributors

…s on PR-apply

Fixes both halves of the "labels auto-created flat gray on first use" problem on
freshly onboarded repos (labels stayed gray until the weekly org sweep):

1. sync-org-labels gains an optional `repos` input (comma / space / newline
   separated, each with or without an owner/ prefix). When set, the sync targets
   just those repos instead of always sweeping /orgs/{org}/repos; empty keeps the
   full-org sweep, so the weekly cron / manual org dispatch is unchanged. Plumbed
   through the reusable workflow and the composite action.

2. sync-pr-labels now seeds/corrects each label it is about to apply from
   data/github-labels.json before applying it (new `ensure-catalog-labels` input,
   default true), so POST /issues/{n}/labels finds the labels already present with
   the catalog's color/description instead of silently auto-creating them flat
   gray. Cheap in steady state (one list call, zero writes once correct).

The apply-time ensure is deliberately NON-destructive — it only creates or
corrects the labels being applied and never deletes, unlike the full org sync
(which deletes any repo label absent from the catalog). Triggering the full
destructive sync on every PR-label apply would strip a repo's custom labels
mid-PR, so the on-demand single-repo full sync is exposed via part 1's `repos`
input instead. Best-effort: a missing catalog or insufficient token scope warns
and lets the apply proceed unchanged.

Fixes #263
@cldmv-bot cldmv-bot Bot added ! feature → next v4 flow: contributor PR targeting the next integration branch type: feature Implements new functionality — a PR or issue that adds a feature area: core Touches core library / runtime source code type: ci Changes to CI workflows, actions, or build pipelines labels Sep 3, 2026
@Shinrai
Shinrai requested a lite review from Copilot September 4, 2026 23:28

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Changes recommended

The new catalog-seeding path can still fail the action on a malformed-but-parseable label catalog, contradicting the intended “best-effort, never block apply” behavior.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

This PR enhances the org label management tooling by (1) allowing org label sync to be scoped to an explicit repo list and (2) ensuring PR label application seeds/corrects labels from the shared label catalog so repos don’t get GitHub’s default gray auto-created labels.

Changes:

  • Add a repos input to the org-label sync workflow and underlying sync job/action to optionally scope syncing to specific repositories.
  • Extend the PR label sync step with an ensure-catalog-labels input (default on) that creates/updates the labels being applied based on data/github-labels.json before applying them.
File summaries
File Description
.github/workflows/workflow-sync-org-labels.yml Adds a repos workflow input and forwards it into the sync job to allow scoped org-label sync runs.
.github/actions/github/jobs/sync-org-labels/action.yml Adds repos input and passes it to the sync script via REPOS env var.
.github/actions/github/jobs/sync-org-labels/sync.mjs Implements scoped repo selection when REPOS is provided; otherwise preserves full-org sweep behavior.
.github/actions/github/steps/sync-pr-labels/action.yml Adds ensure-catalog-labels input (default true) to control catalog seeding behavior.
.github/actions/github/steps/sync-pr-labels/action.mjs Implements best-effort label catalog seeding/correction before applying PR labels.
Review details
  • Files reviewed: 5/5 changed files
  • Comments generated: 1
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

…atalog

A data/github-labels.json that parses as valid JSON but isn't an array (e.g. an
object) passed the read/parse try/catch, then threw an uncaught TypeError at
`for (const entry of catalog)` — propagating to the top-level handler and
failing the whole label-apply step, the opposite of the documented best-effort
contract. Add an Array.isArray guard that skips cleanly with a warning, and make
the read/parse warning resilient to a non-Error throw.

Addresses Copilot review on PR #266.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟢 Approval recommended

The changes are additive, backward-compatible, and the new catalog-seeding behavior is explicitly best-effort with appropriate guards to avoid blocking label application.

Review details
  • Files reviewed: 5/5 changed files
  • Comments generated: 0 new
  • Review effort level: Lite

Shinrai
Shinrai previously approved these changes Sep 5, 2026

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Changes recommended

The new catalog-label ensure path can redundantly re-ensure duplicate labels (extra API calls/noisy warnings) unless label names are deduplicated first.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Review details
  • Files reviewed: 5/5 changed files
  • Comments generated: 1
  • Review effort level: Lite

Addressing Copilot review on #266: ensureCatalogLabels mapped the incoming
labels straight to catalog entries, so multiple aliases resolving to the same
canonical label ensured it more than once — redundant API calls and a noisy 422
on the second create. Resolve to entries deduped by canonical (lowercased) name.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔵 Needs a closer look

The new REPOS parsing can yield empty repo names (or a misleading 0-repo scoped run) due to filtering before stripping owner/, leading to invalid API calls or unintended no-ops.

Review details

Suppressed comments (1)

Previously missed (1) — in code that hasn't changed since the last review.

.github/actions/github/jobs/sync-org-labels/sync.mjs:435

  • REPOS parsing filters empties before stripping an optional owner/ prefix, so inputs like CLDMV/ (or separators-only like ,) can produce an empty repo name and/or an empty names list while still taking the scoped-sync path. That results in invalid /repos/${ORG}/ API calls or a misleading “scoped to 0 repos” no-op instead of falling back to the default full-org sweep.
  • Files reviewed: 5/5 changed files
  • Comments generated: 0 new
  • Review effort level: Lite

…n empty

Addressing a Copilot suppressed finding on #266: the REPOS scoping parse ran
.filter(Boolean) BEFORE stripping the optional owner/ prefix, so 'CLDMV/' (or a
separators-only input) produced an empty repo name → invalid GET /repos/{org}/
calls, or a misleading 'scoped to 0 repos' no-op instead of the full-org sweep.
Now strip owner/ and trim first, THEN filter empties, and fall back to the
full-org sweep (with a note) when nothing resolves.
@Shinrai

Shinrai commented Sep 6, 2026

Copy link
Copy Markdown
Contributor

Addressed the suppressed finding from the last review (sync-org-labels/sync.mjs — the REPOS scoping parse ran .filter(Boolean) before stripping the optional owner/, so CLDMV/ or a separators-only input yielded an empty repo name → invalid GET /repos/{org}/ calls or a misleading "scoped to 0 repos" no-op). Fixed in 68c8f3923: strip owner/ + trim first, then filter empties, and fall back to the full-org sweep (with a note) when nothing resolves. Verified: CLDMV/ and , → full-org fallback; CLDMV/foo bar → [foo, bar]; dupes deduped.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟢 Approval recommended

The changes are self-contained, align with existing API helper patterns in the repo, and include appropriate best-effort/error-tolerant behavior for the new label-seeding step.

Review details
  • Files reviewed: 5/5 changed files
  • Comments generated: 0 new
  • Review effort level: Lite

@Shinrai
Shinrai merged commit c402a8e into next Sep 6, 2026
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: core Touches core library / runtime source code ! feature → next v4 flow: contributor PR targeting the next integration branch type: ci Changes to CI workflows, actions, or build pipelines type: feature Implements new functionality — a PR or issue that adds a feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants