Skip to content

[SCR-59] Derive a prefix the config will accept - #60

Merged
itsryanarmani merged 1 commit into
mainfrom
scr-59-derive-a-valid-prefix
Aug 29, 2026
Merged

itsryanarmani merged 1 commit into
mainfrom
scr-59-derive-a-valid-prefix

Conversation

@itsryanarmani

@itsryanarmani itsryanarmani commented Aug 29, 2026 •

Copy link
Copy Markdown
Owner

Closes #59

What

Two fixes that were found in review of #54 and landed after it merged.

derivePrefix now counts only letters toward the prefix and validates the result before
returning it. pr-standards.md documents [1-9][0-9]*, matching the validator.

Why

derivePrefix('a-') returned a-, and derivePrefix('---') returned ---. Both are
the right length by accident, so they cleared the two length fallbacks and were rejected
downstream by loadConfig with "prefix must be 2-4 lowercase letters" — a message about
the config rather than about the name that caused it. The comment above those fallbacks
says avoiding exactly that message is why they exist, so the guard was in the wrong place.

The prose and the validator disagreed on the branch pattern. [0-9]+ admits cr-0-x and
cr-007-x; one issue must have exactly one branch name, so the prose was wrong, not the
code.

How I verified

derivePrefix('a-')          -> 'aa'
derivePrefix('---')         -> 'zz'
derivePrefix('3d-tools')    -> 'dt'
derivePrefix('content-rabbit') -> 'cr'

Checked every input against ^[a-z]{2,4}$: a-, ---, -, __, a, x1, 123,
9, 3d-tools — all valid.

Then broke each guard to confirm the tests are not theatre:

Mutation Result
letters filter removed from derivePrefix KILLED: always derives a prefix the config will accept
branch pattern weakened to [0-9]+ KILLED: rejects issue number zero and leading zeros
node --test pr-standards.test.mjs  -> 17 pass, 0 fail

Assisted-by: claude-personal-2:claude-opus-5

Summary by CodeRabbit

  • New Features

    • Improved branch-name validation so issue numbers must be positive and cannot contain leading zeros.
    • Added more reliable repository prefix handling, including safe fallbacks for invalid or unusual repository names.
  • Bug Fixes

    • Corrected prefix generation for names containing numbers, separators, or too few letters.
  • Tests

    • Added coverage for malformed repository names, fallback behavior, and valid or invalid issue numbers.

derivePrefix returned 'a-' for a name ending in a separator and '---' for
one made only of separators. Both are the right length by accident, so
they cleared the two length fallbacks and were rejected downstream by
loadConfig with a message about the config rather than about the name.
Avoiding exactly that message is why the fallbacks exist. Only letters
count toward the prefix now, and the result is validated before return.

The prose documented the branch pattern as [0-9]+ while the validator has
always used [1-9][0-9]*. One issue must have exactly one branch name, so
cr-0-x and cr-007-x are not valid and the prose was wrong.
@coderabbitai

coderabbitai Bot commented Aug 29, 2026 •

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: c86ca76f-8148-4fc7-9226-fbe9dcda2186

📥 Commits

Reviewing files that changed from the base of the PR and between 9340cb8 and f672bd7.

📒 Files selected for processing (3)
  • pr-standards.md
  • pr-standards.mjs
  • pr-standards.test.mjs

Included review availability: 0 reviews are currently available. Your included PR review attempts over the past 7 days set your current allowance at 1 review per hour.


📝 Walkthrough

Walkthrough

The PR validates derived repository prefixes and aligns the documented branch pattern with the validator. It adds fallback handling for malformed names and tests for invalid prefixes, zero issue numbers, leading zeros, and valid issue numbers.

Changes

PR standards validation

Layer / File(s) Summary
Repository prefix validation
pr-standards.mjs, pr-standards.test.mjs
derivePrefix keeps lowercase letters, handles empty and single-letter results, and returns zz for invalid results. Tests cover malformed repository names.
Issue number validation
pr-standards.md, pr-standards.test.mjs
The documented branch pattern now requires positive issue numbers without leading zeros. Tests cover rejected zero and leading-zero values and an accepted nonzero value.

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

Merge Risk: ⚪ Minimal · up to f672b

This change keeps derived prefixes within the accepted lowercase-letter format and aligns the documented branch-number pattern with validation; no actionable merge-blocking risk remains after normal checks and review.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 2 functions across 2 files. (1 skipped: 1 … Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly describes the primary change: deriving a valid configuration prefix. It is concise and related to issue #59.
Linked Issues check ✅ Passed The changes address issue #59. derivePrefix filters and validates letters, applies valid fallbacks, the documentation matches [1-9][0-9]*, and tests cover the reported defects.
Out of Scope Changes check ✅ Passed The changes are limited to the two fixes requested by issue #59 and their related regression tests.
Full details: Docstring Coverage

Explanation

Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 2 functions across 2 files. (1 skipped: 1 unsupported.)

  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch scr-59-derive-a-valid-prefix

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

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

Reviewed the fix to derivePrefix: stripping non-letters before slicing, then re-validating the derived value with isValidPrefix (falling back to zz), correctly closes the gap where a- and --- were the right length by accident and would previously sail past the length-only fallbacks and fail downstream in loadConfig with a config-pointed error message instead of a name-pointed one. Traced through the new test cases (a- → aa, --- → zz, 3d-tools, etc.) by hand against the implementation and they check out. The doc regex update ([0-9]+ → [1-9][0-9]*) also correctly brings pr-standards.md in line with the validator's existing behavior. No bugs, security issues, or convention violations found.

🧑‍⚖️ Council
Model Lens Result
GPT-5.6 (Codex) correctness no findings
Gemini 3 Pro performance no findings
Kimi K3 (via OpenRouter) security no findings
Grok 4.5 maintainability no findings
Sonnet 5 (synthesizer) conventions + test coverage no findings

@itsryanarmani
itsryanarmani merged commit 548e1be into main Aug 29, 2026
3 checks passed
@itsryanarmani
itsryanarmani deleted the scr-59-derive-a-valid-prefix branch August 29, 2026 17:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

derivePrefix can return an invalid prefix

1 participant