Skip to content

Unify job-name normalizers and split grab-bag stringutil.go - #54702

Open
pelikhan with Copilot wants to merge 5 commits into
mainfrom
copilot/refactor-stringutil-stats
Open

Unify job-name normalizers and split grab-bag stringutil.go#54702
pelikhan with Copilot wants to merge 5 commits into
mainfrom
copilot/refactor-stringutil-stats

Conversation

Copilot AI commented Aug 22, 2026

Copy link
Copy Markdown
Contributor

Three call sites reimplemented job-name normalization independently and disagreed on canonical form (hyphen vs. underscore), and stringutil.go had become a grab-bag file mixing unrelated concerns.

Canonical hyphen-form normalizer

  • Added stringutil.NormalizeIdentifierToHyphens, the hyphen-canonical counterpart to the existing NormalizeSafeOutputIdentifier (underscore-canonical), converting _ and . to -.
  • Documented, tested (unit + spec test), and added to the package README following existing conventions.

Collapsed divergent call sites onto canonical helpers

  • sanitizeJobName (pkg/workflow/strings.go) previously round-tripped through NormalizeSafeOutputIdentifier and immediately undid it — now calls NormalizeIdentifierToHyphens directly:
    func sanitizeJobName(workflowName string) string {
        return stringutil.NormalizeIdentifierToHyphens(workflowName)
    }
  • normalizeMaintenanceJobName (pkg/workflow/repo_config.go) now delegates its separator normalization to NormalizeIdentifierToHyphens after lowercasing/trimming.
  • normalizeJobName (pkg/cli/logs_report.go) now delegates to NormalizeSafeOutputIdentifier after lowercasing/trimming/space-handling.
  • Known maintenance job names never contain periods, so the added period handling is not a behavior change for supported inputs (documented at the call site).

Split stringutil.go grab-bag

  • whitespace.go: NormalizeWhitespace, NormalizeLeadingWhitespace
  • version.go: ParseVersionValue
  • stringutil.go: now only Truncate, FormatList, IsPositiveInteger
  • Corresponding tests moved alongside their functions; README updated to reflect the new file organization.

Generated by 👨‍🍳 PR Sous Chef · gpt54 · 12.3 AIC · ⌖ 8.33 AIC · ⊞ 7K ·
Comment /souschef to run again

Copilot AI and others added 2 commits August 22, 2026 03:12
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
…eJobName

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI changed the title [WIP] Refactor string utility job-name normalizers Unify job-name normalizers and split grab-bag stringutil.go Aug 22, 2026
Copilot AI requested a review from pelikhan August 22, 2026 03:14
@pelikhan
pelikhan marked this pull request as ready for review August 22, 2026 03:15
Copilot AI balanced review requested due to automatic review settings August 22, 2026 03:15
@github-actions

github-actions Bot commented Aug 22, 2026

Copy link
Copy Markdown
Contributor

🧠 Matt Pocock Skills Reviewer has completed the skills-based review. ✅

🧠 Reviewed using Matt Pocock's skills by Matt Pocock Skills Reviewer

@github-actions

github-actions Bot commented Aug 22, 2026

Copy link
Copy Markdown
Contributor

PR Code Quality Reviewer completed the code quality review.

🔎 Code quality review by PR Code Quality Reviewer

@github-actions

github-actions Bot commented Aug 22, 2026

Copy link
Copy Markdown
Contributor

Design Decision Gate 🏗️ failed during design decision gate check.

Warning

Threat Detection Engine Failure — The analysis engine could not complete. This is a tooling failure, not a security finding.

What happened

The threat detection engine failed to produce results.

Review the workflow run logs for details.

🏗️ ADR gate enforced by Design Decision Gate 🏗️

@github-actions

github-actions Bot commented Aug 22, 2026

Copy link
Copy Markdown
Contributor

Test Quality Sentinel completed test quality analysis.

Test Quality Sentinel skipped because pre-fetch PR data was unavailable: unable to fetch test file diff

🧪 Test quality analysis by Test Quality Sentinel

@github-actions

github-actions Bot commented Aug 22, 2026

Copy link
Copy Markdown
Contributor

Ponytail Reviewer completed successfully!

Lean already. Ship.

Generated by Ponytail Reviewer for #54702

@github-actions

Copy link
Copy Markdown
Contributor

Comment Memory

reviewed_at: 2026-08-22T03:18:39Z
review_event: REQUEST_CHANGES
top_themes:
  - behavior change in dotted job-name normalization without compatibility coverage
  - missing workflow-level tests for generated job IDs after canonicalization change
files_reviewed:
  - pkg/cli/logs_report.go
  - pkg/stringutil/README.md
  - pkg/stringutil/identifiers.go
  - pkg/stringutil/identifiers_test.go
  - pkg/stringutil/spec_test.go
  - pkg/stringutil/stringutil.go
  - pkg/stringutil/stringutil_test.go
  - pkg/stringutil/version.go
  - pkg/stringutil/version_test.go
  - pkg/stringutil/whitespace.go
  - pkg/stringutil/whitespace_test.go
  - pkg/workflow/repo_config.go
  - pkg/workflow/strings.go
comment_count: 0

Note

This comment is managed by comment memory.

It stores persistent context for this thread in the code block at the top of this comment.
Edit only the text inside the backtick fences; workflow metadata and the footer are regenerated automatically.

Learn more about comment memory

🔎 Code quality review by PR Code Quality Reviewer · gpt54 · 28.6 AIC · ⌖ 10.2 AIC · ⊞ 7K ·
Comment /review to run again

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Requesting changes

This refactor changes job-name normalization semantics without proving the new . handling is safe for existing workflow names, and there are no workflow-level tests covering that compatibility boundary.

Blocking themes
  • sanitizeJobName and maintenance-job normalization now rewrite periods to hyphens, which is a behavior change for any existing dotted identifiers.
  • The PR adds unit/spec tests for the helper itself but does not add an end-to-end compiler test showing dotted workflow names still resolve correctly through generated job IDs and references.

🔎 Code quality review by PR Code Quality Reviewer · gpt54 · 28.6 AIC · ⌖ 10.2 AIC · ⊞ 7K
Comment /review to run again

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR centralizes job-name separator normalization and reorganizes stringutil into focused modules without changing existing utility behavior.

Changes:

  • Adds and tests hyphen-canonical identifier normalization.
  • Updates three job-name normalization call sites to use shared helpers.
  • Moves whitespace and version utilities into dedicated files.
Show a summary per file
File Description
pkg/workflow/strings.go Uses the hyphen normalizer for job names.
pkg/workflow/repo_config.go Centralizes maintenance job normalization.
pkg/cli/logs_report.go Uses canonical safe-output normalization.
pkg/stringutil/identifiers.go Adds the hyphen-canonical helper.
pkg/stringutil/identifiers_test.go Tests and benchmarks the new helper.
pkg/stringutil/spec_test.go Adds public API specification coverage.
pkg/stringutil/whitespace.go Houses whitespace normalization utilities.
pkg/stringutil/whitespace_test.go Moves corresponding tests and benchmarks.
pkg/stringutil/version.go Houses version-value coercion.
pkg/stringutil/version_test.go Moves version coercion tests.
pkg/stringutil/stringutil.go Retains general-purpose helpers.
pkg/stringutil/stringutil_test.go Removes tests relocated with their implementations.
pkg/stringutil/README.md Documents the new helper and file organization.

Review details

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

  • Files reviewed: 13/13 changed files
  • Comments generated: 0
  • Review effort level: Balanced

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Skills-Based Review 🧠

Applied /codebase-design — requesting minor changes on two navigability issues left by the refactor.

📋 Key Themes & Highlights

Key Themes

  • Stale inline comment (compiler_safe_output_jobs.go:194): describes the old two-step implementation; should be updated to match the new direct delegation
  • Incomplete doc catalogue (strings.go:36): the "Normalize Pattern" registry doesn't list NormalizeIdentifierToHyphens, which is now used in the same file

Positive Highlights

  • ✅ Clean elimination of three divergent reimplementations — the canonical NormalizeIdentifierToHyphens is a well-named, well-documented deep module
  • ✅ Excellent test coverage: unit tests, spec tests, and benchmarks all added for the new function
  • sanitizeJobName is now a single, intention-revealing line — a clear win
  • ✅ README updated and file split into focused concerns — highly navigable

🧠 Reviewed using Matt Pocock's skills by Matt Pocock Skills Reviewer · sonnet46 · 52.1 AIC · ⌖ 11 AIC · ⊞ 7.6K
Comment /matt to run again

Comments that could not be inline-anchored

pkg/workflow/strings.go:36

[/codebase-design] The "Normalize Pattern" doc block at line ~36 lists only NormalizeSafeOutputIdentifier as a normalize helper, but sanitizeJobName in this same file now delegates to NormalizeIdentifierToHyphens. The registry is incomplete after the refactor.

<details>
<summary>💡 Suggested fix</summary>

Add the new function to the list:

//   - stringutil.NormalizeIdentifierToHyphens: Converts underscores/periods to hyphens (job names)

Keeping the catalogue accurate is …

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Clean refactoring. The behavioral equivalence between old and new paths is correct:

  • sanitizeJobName: the old two-step (NormalizeSafeOutputIdentifier → underscores, then _-) is exactly equivalent to the new single-step NormalizeIdentifierToHyphens (. and _-). ✅
  • normalizeJobName: now also replaces . with _ via NormalizeSafeOutputIdentifier, a harmless expansion since GitHub Actions job names do not use periods. ✅

The file split is well-structured and the new function is properly documented and tested.

🧵 Reviewed using Impeccable skills by Impeccable Skills Reviewer · sonnet46 · 42.5 AIC · ⌖ 8.97 AIC · ⊞ 6.2K

@gh-aw-bot

Copy link
Copy Markdown
Collaborator

@copilot this PR still needs forward progress before maintainer review.

Run: https://github.com/github/gh-aw/actions/runs/32553383419

Generated by 👨‍🍳 PR Sous Chef · gpt54 · 12.3 AIC · ⌖ 8.33 AIC · ⊞ 7K ·
Comment /souschef to run again

Co-authored-by: gh-aw-bot <259018956+gh-aw-bot@users.noreply.github.com>

Copilot AI commented Aug 22, 2026

Copy link
Copy Markdown
Contributor Author

@copilot this PR still needs forward progress before maintainer review.

  • Unresolved review feedback remains around the job-name normalization behavior change and missing compatibility coverage/tests...

Addressed in 0bbbd5d: restored period-preserving matching where separators are not equivalent, added dotted workflow compiler coverage for generated job IDs, conditions, and paths, and updated normalization documentation. Focused packages and the repository lint/test/recompile pass completed; the prior impacted-test failure was a missing origin/main merge-base and custom-lint failures are pre-existing diagnostics outside this PR.

@github-actions

Copy link
Copy Markdown
Contributor

PR Triage

  • Category: refactor
  • Risk: medium
  • Priority score: 38/100 (impact 10, urgency 20, quality 8)
  • Recommended action: batch_review
  • CI status: failing
  • Batch: batch-1

Generated by 🔧 PR Triage Agent · auto · 82.9 AIC · ⌖ 6.65 AIC · ⊞ 8.3K ·

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[refactor] stringutil/stats: divergent job-name normalizers and grab-bag stringutil.go

4 participants