Unify job-name normalizers and split grab-bag stringutil.go#54702
Conversation
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
…eJobName Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
|
🧠 Matt Pocock Skills Reviewer has completed the skills-based review. ✅
|
|
✅ PR Code Quality Reviewer completed the code quality review.
|
|
❌ 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 happenedThe threat detection engine failed to produce results. Review the workflow run logs for details.
|
|
✅ Test Quality Sentinel completed test quality analysis. Test Quality Sentinel skipped because pre-fetch PR data was unavailable: unable to fetch test file diff
|
|
✅ Ponytail Reviewer completed successfully! Lean already. Ship.
|
Comment MemoryNote This comment is managed by comment memory.It stores persistent context for this thread in the code block at the top of this comment.
|
There was a problem hiding this comment.
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
sanitizeJobNameand 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
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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 listNormalizeIdentifierToHyphens, which is now used in the same file
Positive Highlights
- ✅ Clean elimination of three divergent reimplementations — the canonical
NormalizeIdentifierToHyphensis a well-named, well-documented deep module - ✅ Excellent test coverage: unit tests, spec tests, and benchmarks all added for the new function
- ✅
sanitizeJobNameis 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 …
There was a problem hiding this comment.
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-stepNormalizeIdentifierToHyphens(.and_→-). ✅normalizeJobName: now also replaces.with_viaNormalizeSafeOutputIdentifier, 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
|
@copilot this PR still needs forward progress before maintainer review.
Run: https://github.com/github/gh-aw/actions/runs/32553383419
|
Co-authored-by: gh-aw-bot <259018956+gh-aw-bot@users.noreply.github.com>
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 |
PR Triage
|
Three call sites reimplemented job-name normalization independently and disagreed on canonical form (hyphen vs. underscore), and
stringutil.gohad become a grab-bag file mixing unrelated concerns.Canonical hyphen-form normalizer
stringutil.NormalizeIdentifierToHyphens, the hyphen-canonical counterpart to the existingNormalizeSafeOutputIdentifier(underscore-canonical), converting_and.to-.Collapsed divergent call sites onto canonical helpers
sanitizeJobName(pkg/workflow/strings.go) previously round-tripped throughNormalizeSafeOutputIdentifierand immediately undid it — now callsNormalizeIdentifierToHyphensdirectly:normalizeMaintenanceJobName(pkg/workflow/repo_config.go) now delegates its separator normalization toNormalizeIdentifierToHyphensafter lowercasing/trimming.normalizeJobName(pkg/cli/logs_report.go) now delegates toNormalizeSafeOutputIdentifierafter lowercasing/trimming/space-handling.Split
stringutil.gograb-bagwhitespace.go:NormalizeWhitespace,NormalizeLeadingWhitespaceversion.go:ParseVersionValuestringutil.go: now onlyTruncate,FormatList,IsPositiveInteger