Skip to content

[WRONG BRANCH] fix(grok): don't treat nested [model.x.y] sub-tables as alias collisions - #240

Closed
luvs01 wants to merge 1 commit into
mainfrom
codex/propose-fix-for-grok-alias-collision-issue
Closed

[WRONG BRANCH] fix(grok): don't treat nested [model.x.y] sub-tables as alias collisions#240
luvs01 wants to merge 1 commit into
mainfrom
codex/propose-fix-for-grok-alias-collision-issue

Conversation

@luvs01

@luvs01 luvs01 commented Aug 10, 2026

Copy link
Copy Markdown
Owner

Motivation

  • A recent change conservatively reserved aliases when it matched [model.<alias>.<...>] sub-table headers, causing harmless user sub-tables like [model.ocx-mine.extra] to force generated aliases to be suffixed (e.g. ocx-mine-2).
  • This produced a functional regression by destabilizing generated Grok model aliases even when TOML semantics permit defining the parent table later.

Description

  • Tighten the model-table header matcher to only capture two-segment [model.<alias>] headers (and [[model.<alias]] arrays) by removing the optional sub-table tail from MODEL_TABLE_HEADER in src/grok/inject.ts.
  • Update the surrounding comment to clarify that sub-tables ([model.x.extra]) do not collide with an explicitly emitted parent table under TOML semantics.
  • Add a focused regression test in tests/grok-config-inject.test.ts that ensures a user-owned sub-table does not reserve the alias and that the stable [model.ocx-mine] is emitted without a -2 suffix.

Testing

  • Ran bun run typecheck and it completed successfully.
  • Ran the focused spec with the CI Bun version using npx --yes bun@1.3.14 test tests/grok-config-inject.test.ts and all tests in that file passed (43 tests, 0 failures).
  • A run of bun test tests/grok-config-inject.test.ts with the preinstalled Bun (v1.2.14) failed due to a missing node:zlib export in that runtime; re-running with the repository CI Bun (1.3.14) produced the green focused test run above.
  • Kicked off the broader test run with npx --yes bun@1.3.14 run test; the full suite exercised many unrelated environment-sensitive tests and was interrupted after unrelated failures, while the focused regression and typecheck succeeded.

Codex Task

Summary by CodeRabbit

  • Bug Fixes

    • Model aliases can now be generated without unnecessary suffixes when similarly named sub-tables are present.
    • Configuration parsing correctly distinguishes model headers from nested sub-table headers.
  • Tests

    • Added coverage confirming that nested model configuration sections do not reserve the parent model alias.

@github-actions

Copy link
Copy Markdown

Deterministic PR hygiene checks passed.

@coderabbitai

coderabbitai Bot commented Aug 10, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

The change narrows model alias collision detection to plain and array-of-table headers. Tests confirm that nested model sub-tables remain valid without forcing a suffix on the generated parent alias.

Changes

Model alias detection

Layer / File(s) Summary
Header detection and validation
src/grok/inject.ts, tests/grok-config-inject.test.ts
MODEL_TABLE_HEADER now matches only plain and array-of-table model.<alias> headers. Tests remove nested sub-tables from collision cases and verify that [model.ocx-mine.extra] allows generated [model.ocx-mine].

Estimated code review effort: 2 (Simple) | ~10 minutes

Suggested reviewers: lidge-jun

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main fix: nested model sub-tables no longer cause alias collisions.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/propose-fix-for-grok-alias-collision-issue

Comment @coderabbitai help to get the list of available commands.

@github-actions github-actions Bot added the bug Something isn't working label Aug 10, 2026
@github-actions github-actions Bot changed the title fix(grok): don't treat nested [model.x.y] sub-tables as alias collisions [WRONG BRANCH] fix(grok): don't treat nested [model.x.y] sub-tables as alias collisions Aug 10, 2026
@github-actions

github-actions Bot commented Aug 10, 2026

Copy link
Copy Markdown

⏳ DRAFT

  • wrong target branch (main); retarget to dev.

What to do

  • Retarget this PR to dev — all contributions go to dev.

Its title has been prefixed with [WRONG BRANCH].
This pull request was already a draft. Its draft status will be preserved after every issue above is resolved.

@github-actions
github-actions Bot marked this pull request as draft August 10, 2026 03:01

@chatgpt-codex-connector chatgpt-codex-connector Bot 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 4e85ab4bc4

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/grok/inject.ts

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

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/grok/inject.ts`:
- Around line 79-80: Make MODEL_TABLE_HEADER matching TOML-aware by ensuring
header-like lines inside multiline string values are ignored, either by tracking
multiline-string state while scanning or by parsing TOML before identifying
table headers. Preserve alias reservation only for actual model table headers,
and add a regression case in tests/grok-config-inject.test.ts containing a
complete header-looking line inside a multiline string.
- Around line 79-80: Update MODEL_TABLE_HEADER and ANY_TABLE_HEADER to require
matching single- or double-bracket table delimiters, preventing mismatched forms
such as [model.foo]] and [[model.foo]. Ensure capture groups remain aligned with
the match[1]/match[2] consumers or update those consumers accordingly. Adjust
the raw gm scan to ignore header-like text inside multiline TOML strings by
masking or structurally parsing those strings before applying the header
regexes.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: a92b7b4b-a968-4505-9f02-6a6f0069b561

📥 Commits

Reviewing files that changed from the base of the PR and between 121f1ad and 4e85ab4.

📒 Files selected for processing (2)
  • src/grok/inject.ts
  • tests/grok-config-inject.test.ts

Comment thread src/grok/inject.ts
@luvs01 luvs01 closed this Aug 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

aardvark bug Something isn't working codex

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant