Skip to content

Fixing model name normalizer logic - #49001

Merged
pelikhan merged 4 commits into
mainfrom
copilot/fix-model-name-normalizer-code
Jul 30, 2026
Merged

Fixing model name normalizer logic#49001
pelikhan merged 4 commits into
mainfrom
copilot/fix-model-name-normalizer-code

Conversation

Copilot AI commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Pull request created by AI Agent


Generated by 👨‍🍳 PR Sous Chef · gpt54 · 14.8 AIC · ⌖ 5.8 AIC · ⊞ 7.8K ·
Comment /souschef to run again


Generated by 👨‍🍳 PR Sous Chef · gpt54 · 19.3 AIC · ⌖ 8.85 AIC · ⊞ 7.8K ·
Comment /souschef to run again


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

Generated by 👨‍🍳 PR Sous Chef · gpt54 · 5.5 AIC · ⌖ 8.58 AIC · ⊞ 7.8K ·
Comment /souschef to run again

…ToIdentifier

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
@pelikhan
pelikhan marked this pull request as ready for review July 29, 2026 22:29
Copilot AI review requested due to automatic review settings July 29, 2026 22:29
@github-actions

github-actions Bot commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Test Quality Sentinel completed test quality analysis.

Warning

threat detection engine error
The threat detection engine encountered an error and could not complete analysis. This is a tooling failure, not a security finding.

Details

The threat detection engine failed to produce results.

Review the workflow run logs for details.

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

Updates model alias normalization to preserve short model names.

Changes:

  • Returns normalized names shorter than six characters unchanged.
  • Adds tests for model families, fallbacks, casing, and legends.
Show a summary per file
File Description
actions/setup/js/model_aliases.cjs Adds short-name handling.
actions/setup/js/model_aliases.test.cjs Adds normalization tests.

Review details

Tip

Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

  • Files reviewed: 2/2 changed files
  • Comments generated: 1
  • Review effort level: Medium

Comment thread actions/setup/js/model_aliases.cjs Outdated
return normalized;
}

if (normalized.length < 6) {
@github-actions

github-actions Bot commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Design Decision Gate 🏗️ completed the design decision gate check.

No ADR enforcement needed: PR does not have the implementation label and has 0 new lines of code in business logic directories.

@github-actions

github-actions Bot commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

PR Code Quality Reviewer completed the code quality review.

@github-actions

github-actions Bot commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

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

@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.

The fix is correct and well-tested. The length < 6 guard cleanly short-circuits short model names before the version-extraction pipeline can mangle them. Test coverage covers the relevant edge cases (short names, known families, fallback). No issues found.

🧵 Reviewed using Impeccable skills by Impeccable Skills Reviewer · sonnet46 · 20.2 AIC · ⌖ 4.74 AIC · ⊞ 5.3K

@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.

🔎 Code quality review by PR Code Quality Reviewer · auto · 20.2 AIC · ⌖ 4.58 AIC · ⊞ 7.8K
Comment /review to run again

Comment thread actions/setup/js/model_aliases.cjs Outdated
return normalized;
}

if (normalized.length < 6) {

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.

This new short-circuit breaks alias consistency for known model families whose raw name is under 6 chars (e.g. gpt-4gpt-4, o1-minio10mini, gem-3gem-3), causing the same family to produce wildly different alias formats depending on string length alone.

💡 Inconsistent aliasing for short known-family names

Verified via direct execution:

reduceModelNameToIdentifier("gpt-4")   -> "gpt-4"   (bypasses normalization, raw string kept)
reduceModelNameToIdentifier("gpt-4o")  -> "gpt40"   (normalized as expected)
reduceModelNameToIdentifier("gem-3")   -> "gem-3"   (bypasses normalization)

The < 6 length check runs before the family-shortcut loop, so it intercepts recognized families (gpt, o-series, gem, etc.) whenever the raw name happens to be short, defeating the whole purpose of the normalizer for exactly the names most likely to appear in short form (gpt-4, gpt-5, o1-5). This also means the emoji-alias legend can show both gpt-4=gpt-4 and gpt40=gpt-4o for the same family, which is confusing to end users and inconsistent with the stated goal of a "deterministic compact model identifier."

Suggested fix: move the length check after the shortcuts loop (as a fallback-only guard), or make it conditional on none of the familyPatterns matching:

const isKnownFamily = shortcuts.some(({ familyPattern }) => familyPattern.test(normalized));
if (!isKnownFamily && normalized.length < 6) {
  return normalized;
}

@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 /tdd and /diagnosing-bugs — requesting changes on one correctness issue and two test-quality gaps.

📋 Key Themes

Issues

  • Broken test syntax (critical): model_aliases.test.cjs uses ESM import in a .cjs file. Node treats .cjs as CommonJS; import will throw a SyntaxError unless vitest has a special transform override for this extension. The tests cannot be trusted until this is resolved.
  • Missing boundary test: the length < 6 guard has no test at exactly 6 characters — the threshold itself is unverified.
  • Guard ordering undocumented: the interaction between the exact-name guard (opus/sonnet/haiku) and the new length guard is non-obvious; a short comment would prevent future misreordering.

Positive Highlights

  • ✅ Minimal, correctly placed fix
  • ✅ Good edge-case coverage (null, undefined, empty string)
  • ✅ Known model families (Claude, GPT, Gemini) tested end-to-end

🧠 Reviewed using Matt Pocock's skills by Matt Pocock Skills Reviewer · sonnet46 · 28.9 AIC · ⌖ 5.14 AIC · ⊞ 7K
Comment /matt to run again

// @ts-check

import { describe, expect, it } from "vitest";
import { createRequire } from "module";

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.

[/tdd] ESM import statement in a .cjs file will fail at runtime.

Line 4 uses import { describe, expect, it } from "vitest"import is not valid in CommonJS modules. This test file will throw a SyntaxError unless vitest's config applies a transform, but the .cjs extension explicitly opts out of ESM.

💡 Fix

Replace the ESM imports with CommonJS requires:

const { describe, expect, it } = require('vitest');

Or rename the file to .test.mjs and remove the createRequire wrapper since native ESM can use import directly.

@copilot please address this.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

No change needed. Every other .test.cjs file in actions/setup/js/ (e.g. generate_workflow_overview.test.cjs, safe_output_processor.test.cjs) uses the same ESM import syntax. The vitest config (include: ["**/*.test.{js,cjs}"]) transforms these files — confirmed by all 12 tests passing. Changing this file alone would create an inconsistency with the rest of the test suite.

Comment thread actions/setup/js/model_aliases.test.cjs Outdated
expect(reduceModelNameToIdentifier("auto")).toBe("auto");
});

it("returns short model names (< 6 chars) unchanged", () => {

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.

[/tdd] Missing boundary test: length === 6 (the exact cutoff).

The guard normalized.length < 6 is tested on names shorter than 6 chars, but there's no test for a name of exactly 6 characters, which should fall through to version-extraction logic. Without this, a future change to the threshold (e.g. <= 6 or < 5) would go unnoticed.

💡 Suggested test
it('processes a 6-char name through version extraction (boundary)', () => {
  // 'gpt-4o' is exactly 6 chars and matches the gpt family pattern
  expect(reduceModelNameToIdentifier('gpt-4o')).toBe('gpt40');
});

@copilot please address this.

Comment thread actions/setup/js/model_aliases.cjs Outdated
return normalized;
}

if (normalized.length < 6) {

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.

[/diagnosing-bugs] The early-return threshold (< 6) interacts with the earlier exact-string guard for opus, sonnet, haiku (all ≤ 6 chars). Those three names are already handled before this new guard runs, so their cases are fine — but the added guard now silently passes through any other ≤ 5-char string that could match a family pattern (e.g. a future 3-letter model code). A brief inline comment explaining the intentional ordering would prevent future readers from reordering the guards incorrectly.

💡 Suggestion
// NOTE: exact-name shortcuts (opus/sonnet/haiku) are checked above this guard,
// so < 6 chars here means an unrecognised short identifier — return as-is.
if (normalized.length < 6) {
  return normalized;
}

@copilot please address this.

@github-actions

Copy link
Copy Markdown
Contributor

Warning

threat detection engine error
The threat detection engine encountered an error and could not complete analysis. This is a tooling failure, not a security finding.

Details

The threat detection engine failed to produce results.

Review the workflow run logs for details.

Test Quality Sentinel Report - Score 68/100 Acceptable - 10 tests analyzed, 9 design, 1 implementation, 0 violations, 10% implementation tests (threshold 30%). Passed.

🧪 Test quality analysis by Test Quality Sentinel · sonnet46 · 68.8 AIC · ⊞ 8.4K ·
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.

✅ Test Quality Sentinel: 68/100. 10% implementation tests (threshold: 30%). No violations.

@gh-aw-bot

Copy link
Copy Markdown
Collaborator

@copilot please run the pr-finisher skill, address unresolved review feedback, and rerun checks once the branch is up to date.

Reviewer feedback to address:

  • github-actions: ### Skills-Based Review 🧠 Applied /tdd and /diagnosing-bugs — requesting changes on one correctness issue and two test-quality gaps.
    📋 Key Themes #### Issues - **Broken test synta
  • github-actions: - > 🔎 Code quality review by PR Code Quality Reviewer · auto · 20.2 AIC · ⌖ 4.58 AIC · ⊞ 7.8K > Comment /review to run again

Generated by 👨‍🍳 PR Sous Chef · gpt54 · 14.8 AIC · ⌖ 5.8 AIC · ⊞ 7.8K ·
Comment /souschef to run again

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

Copilot AI commented Jul 29, 2026

Copy link
Copy Markdown
Contributor Author

@copilot please run the pr-finisher skill, address unresolved review feedback, and rerun checks once the branch is up to date.

Reviewer feedback to address:...

Addressed in the latest commit. The short-name early return now requires /^[a-z0-9]+$/ — names with non-alphanumeric characters (e.g., a|b, gpt-5) fall through to the family-shortcut matchers or the fallback sanitizer instead of being emitted verbatim. Updated tests: gpt-5 now expects gpt50, and a new test case covers pipe-containing short names to prevent regression.

Copilot AI requested a review from gh-aw-bot July 29, 2026 23:13
@gh-aw-bot

Copy link
Copy Markdown
Collaborator

@copilot please run the pr-finisher skill, address unresolved review feedback, and rerun checks once the branch is up to date.

Unresolved review threads (newest first):

Reviewer feedback to address:

  • github-actions: the current implementation can emit unsafe or inconsistent short aliases and needs boundary coverage and a comment on the guard ordering.

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

Generated by 👨‍🍳 PR Sous Chef · gpt54 · 19.3 AIC · ⌖ 8.85 AIC · ⊞ 7.8K ·
Comment /souschef to run again

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

Copilot AI commented Jul 29, 2026

Copy link
Copy Markdown
Contributor Author

@copilot please run the pr-finisher skill, address unresolved review feedback, and rerun checks once the branch is up to date.

Unresolved review threads (newest first):...

Addressed all unresolved threads in commit 080314f:

  • Guard ordering comment — added a 4-line comment before the short-name guard in model_aliases.cjs explaining that opus/sonnet/haiku are already handled above, and that names with non-alphanumeric characters fall through to the family shortcuts/fallback sanitizer.
  • 6-char boundary test — added a dedicated test case "processes names of exactly 6 characters through normalization (boundary)" that explicitly verifies gpt-4o (6 chars) is not intercepted by the < 6 guard.
  • ESM import in .cjs — no change needed; every other .test.cjs file in actions/setup/js/ uses the same import syntax and vitest's config (include: ["**/*.test.{js,cjs}"]) transforms them. Changing this file alone would create an inconsistency with the rest of the test suite.
  • Known-family aliases inconsistency — covered by the alphanumeric guard added previously; names with hyphens like gpt-4, gem-3 do not satisfy /^[a-z0-9]+$/ and fall through to the family shortcuts, producing consistent normalized output (gpt40, gem30).
  • Unsafe short names (a|b) — covered by the alphanumeric guard and tested.

@gh-aw-bot

Copy link
Copy Markdown
Collaborator

@copilot please run the pr-finisher skill, review the latest feedback on this PR, address any unresolved reviewer requests, and rerun checks once the branch is up to date. Run context: https://github.com/github/gh-aw/actions/runs/30503727864

Generated by 👨‍🍳 PR Sous Chef · gpt54 · 5.5 AIC · ⌖ 8.58 AIC · ⊞ 7.8K ·
Comment /souschef to run again

@github-actions

Copy link
Copy Markdown
Contributor

Triage: Fixing model name normalizer logic

  • Category: bug | Risk: medium | Score: 48/100 (Impact 25, Urgency 15, Quality 8)
  • Recommendation: defer — mixed automated review outcomes (2 approve / 2 changes-requested from github-actions bot). Needs the requested changes addressed before human review.

Generated by 🔧 PR Triage Agent · aut00 · 52.7 AIC · ⌖ 9.26 AIC · ⊞ 7.9K ·

Copilot AI commented Jul 30, 2026

Copy link
Copy Markdown
Contributor Author

@copilot please run the pr-finisher skill, review the latest feedback on this PR, address any unresolved reviewer requests, and rerun checks once the branch is up to date. Run context: https://githu...

All previous changes are already pushed (commit 080314f). Local validation passes (make agent-report-progress — 12/12 tests, 266 workflows lint-clean, zero errors). The latest CI run (30503727864) was a read-only check that completed successfully with no new feedback.

Summary:

  • ✅ Reviews — all actionable threads addressed; replied to the ESM import thread (tests pass, pattern is consistent with the whole test suite).
  • ✅ Checks (local) — make fmt, make lint, make test-unit, make recompile all pass.
  • ❓ Checks (CI) — stale after agent push; needs human re-trigger.
  • ✅ Mergeable — branch is up to date, working tree clean.

Hand-off: CI must be re-triggered (close/reopen PR or push from a maintainer) before merge.

@gh-aw-bot

Copy link
Copy Markdown
Collaborator

@copilot please run the pr-finisher skill, review the latest feedback on this PR, address the unresolved review threads below, and rerun any needed checks once the branch is up to date.

Unresolved review threads (newest first):

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

Generated by 👨‍🍳 PR Sous Chef · gpt54 · 8.44 AIC · ⌖ 7.77 AIC · ⊞ 7.8K ·
Comment /souschef to run again

Copilot AI commented Jul 30, 2026

Copy link
Copy Markdown
Contributor Author

@copilot please run the pr-finisher skill, review the latest feedback on this PR, address the unresolved review threads below, and rerun any needed checks once the branch is up to date.

Unresolved ...

All five threads are addressed in the current HEAD (080314f). Code changes and replies are in place:

  • r3678459860 (unsafe short names) — fixed: /^[a-z0-9]+$/ guard prevents a|b from being emitted verbatim.
  • r3678485952 (known-family inconsistency) — fixed: names with hyphens like gpt-4, gem-3 fail the alphanumeric guard and fall through to the family shortcuts/fallback, producing consistent output.
  • r3678487934 (ESM import in .cjs) — replied: no change; every other .test.cjs file in this directory uses the same pattern and vitest transforms them (12/12 tests pass).
  • r3678487940 (boundary test at length 6) — fixed: "processes names of exactly 6 characters through normalization (boundary)" test added.
  • r3678487944 (guard ordering comment) — fixed: 4-line inline comment added before the guard.

CI run 30507870059 completed successfully with no errors. Local validation passes (12/12 tests, make agent-report-progress green). Thread resolution via the GraphQL API is not accessible from the agent sandbox — a maintainer needs to click "Resolve conversation" on each thread before merge.

@pelikhan
pelikhan merged commit 1553b3e into main Jul 30, 2026
2 checks passed
@pelikhan
pelikhan deleted the copilot/fix-model-name-normalizer-code branch July 30, 2026 05:43
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.

4 participants