fix: auto-correct prefix conflicts in create-new-feature scripts#1829
fix: auto-correct prefix conflicts in create-new-feature scripts#1829daniel-graham wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
Pull request overview
Updates the feature creation Bash script to prevent duplicate spec-directory prefixes when --number is provided and conflicts with an existing specs/NNN-* directory, by auto-correcting to the next available global number.
Changes:
- Added a guardrail that detects existing
specs/${FEATURE_NUM}-*directories and recomputes the feature number from the global maximum across specs and git branches. - Emits a warning to stderr when auto-correction occurs.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
mnriem
left a comment
There was a problem hiding this comment.
Thanks for tackling this — the problem is real and the guardrail idea is the right direction. Before we can merge, there are a few things we need to address: the --number flag's contract changes from a hard override to a suggestion, which is a silent breaking change for any automation relying on deterministic output; the recalculation path skips git fetch so the corrected number could still collide with unfetched remote branches; the check only covers spec directories but not existing branches, leaving an inconsistent experience; the help text still says "overrides auto-detection"; and the PowerShell script doesn't get the same guardrail, breaking cross-platform parity. Could you scope the guardrail to only fire when --number was explicitly passed, add a fetch before recalculating, extend the collision check to branches, update the help text, and port it to the PowerShell side as well?
There was a problem hiding this comment.
Pull request overview
Adds a guardrail to feature creation scripts so an explicitly requested feature number (--number / -Number) is treated as a validated suggestion and auto-corrected when its NNN- prefix already exists, preventing duplicate spec directories/branch prefixes that break downstream workflows.
Changes:
- Add “explicit number” tracking and a conflict check that recalculates the next available number when a requested prefix already exists.
- Update help text to clarify that
--number/-Numberis preferred and may be auto-corrected.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| scripts/bash/create-new-feature.sh | Adds an explicit---number guardrail that detects existing NNN- prefixes and recalculates from global max. |
| scripts/powershell/create-new-feature.ps1 | Mirrors the guardrail behavior in PowerShell and updates CLI help text accordingly. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Changes made in response to reviewThanks for the thorough review @mnriem! All feedback addressed across 3 follow-up commits: @mnriem review (requested changes)
@copilot review (suggestions)
Also fixed
All changes validated on macOS with both Bash and PowerShell (
|
There was a problem hiding this comment.
Pull request overview
Adds guardrails to the “create new feature” scripts so an explicitly suggested feature number won’t silently collide with existing specs/NNN-* directories or existing branch prefixes, preventing downstream prefix-ambiguity errors.
Changes:
- Add prefix-conflict detection and auto-correction when
--number/-Numberis explicitly provided. - Update CLI help text to describe
--number/-Numberas a preferred (validated) number rather than a hard override. - Fix/adjust the
specify.mdcommand template validation step reference (proceed to step 7).
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| templates/commands/specify.md | Updates the command template’s instructions/step reference and removes an unused header. |
| scripts/powershell/create-new-feature.ps1 | Adds -Number explicit-tracking and a guardrail to auto-correct number conflicts; updates help text. |
| scripts/bash/create-new-feature.sh | Adds --number explicit-tracking and a guardrail to auto-correct number conflicts; updates help text. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
mnriem
left a comment
There was a problem hiding this comment.
Please pull in latest from main and address Copilot feedback. If not applicable, please explain why.
ebbfc54 to
f6dbbe2
Compare
Follow-up: rebased on main + addressed remaining feedbackWhat changed
Final PR diffOnly 2 files changed (82 additions, 2 deletions):
No other files are modified. |
There was a problem hiding this comment.
Pull request overview
Updates the “create new feature” scripts to prevent duplicate numeric prefixes (e.g., 001-*) when a caller explicitly suggests a feature number, aligning behavior with downstream tooling that expects unique 3-digit prefixes.
Changes:
- Treat
--number/-Numberas a validated “preferred” value and auto-correct it when the prefix already exists inspecs/or git branches. - Track whether the number was explicitly provided to preserve existing auto-detection behavior.
- Update help text to reflect the new auto-correction semantics.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| scripts/bash/create-new-feature.sh | Adds an explicit-number guardrail to detect prefix conflicts in specs/ and branches and auto-correct to the next available number. |
| scripts/powershell/create-new-feature.ps1 | Mirrors the guardrail behavior in PowerShell and updates CLI help text accordingly. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
mnriem
left a comment
There was a problem hiding this comment.
Please address the additional Copilot comments. Thank for staying with it!
f6dbbe2 to
4fae020
Compare
Latest update (rebased + squashed to 1 commit)Addressed the remaining Copilot feedback and cleaned up from internal review:
Note for @mnriem on range validationWe added If there's an intentional reason to allow values outside Final diff stat |
There was a problem hiding this comment.
Pull request overview
Improves the “create new feature” scripts (bash + PowerShell) so an explicitly provided feature number is treated as a validated suggestion and auto-corrected when the numeric prefix already exists in specs/ or in git branches, preventing duplicate NNN-* spec directories.
Changes:
- Add explicit-number tracking and a conflict guardrail that recomputes the next available global feature number on collision.
- Update CLI help text to clarify
--number/-Numberis auto-corrected on conflicts. - Add input validation for
--number/-Number(but see blocking issues in review comments).
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| scripts/powershell/create-new-feature.ps1 | Adds -Number conflict guardrail + help text update; introduces a parameter validation issue with the default sentinel. |
| scripts/bash/create-new-feature.sh | Adds --number validation and a conflict guardrail to auto-correct prefix collisions after number resolution. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
I would prefer the range to allow for 5 digits so it takes a longer time to run out. Now that we are using AI we probably will go through number more quickly so 3 digits seems a bit small. And please address Copilot feedback. if not applicable please explain why.
Agreed, I imagine we may want to either add some padding 00NNN to existing directories, or leave that up to the user, and have the script simply progress naturally to 5 digits from 999 -> 01000? |
|
Probably should keep the prepending for the current scheme and once it overflows no more prepending as that will keep it backwards compatible |
4fae020 to
05bf2bf
Compare
|
Rebased this PR onto current The revised implementation checks spec directories only and contains no git fetch or branch-scanning path, so the earlier fetch-order and stale-remote comments no longer apply. Current core auto-numbering also derives from spec directories. The earlier 3-digit/5-digit range discussion is superseded by current Bash, PowerShell, and the current Python variant now share these contracts:
Validation on commit
Fresh GitHub workflow runs were created but currently report Posted on behalf of @daniel-graham by Codex (model: GPT-5, autonomous). |
05bf2bf to
83e6df7
Compare
|
Local review loop complete for Fixed five cross-implementation defects:
Validation:
The four workflow runs are awaiting maintainer approval and have not executed the code. Posted on behalf of @daniel-graham by Codex (model: GPT-5, autonomous). |
|
Please address Copilot feedback |
83e6df7 to
8df0359
Compare
| exit 1 | ||
| fi | ||
| BRANCH_NUMBER="$next_arg" | ||
| NUMBER_EXPLICIT=true |
|
Please address Copilot feedback |
Treat an explicit feature number as a preference when an existing spec directory already uses that prefix. Advance to the next available spec prefix and warn without fetching or scanning git branches. Keep Bash, PowerShell, and Python variants aligned. Preserve 64-bit numbering, timestamp mode, dry-run output, matching-file behavior, and exact-directory reuse through the allow-existing option. Assisted-by: Codex (model: GPT-5, autonomous)
8df0359 to
12756f5
Compare
Problem
Passing an explicit feature number can reuse a prefix already owned by another directory under
specs/. Downstream prefix resolution then sees multiple matching feature directories and fails.Solution
Treat an explicit
--number/-Numberas a preferred value:max(spec prefixes), skipping prefixes also owned by timestamp directories, and warn on stderr.--allow-existing-branch/-AllowExistingBranchis supplied, including canonical truncated names and directories with same-prefix siblings.The guardrail intentionally checks local spec directories only. It does not fetch or scan git branches.
Changes
scripts/bash/create-new-feature.sh: track explicit numbers, detect spec-prefix conflicts, and update help text.scripts/powershell/create-new-feature.ps1: mirror Bash behavior with directory-only matching.scripts/python/create_new_feature.py: keep the current Python script variant behaviorally aligned, including unreadable-directory handling.tests/test_timestamp_branches.py: cover correction, 4+ digit continuation, matching files, dry-run behavior, and exact-directory reuse.tests/test_create_new_feature_python_parity.py: verify Bash, PowerShell, and Python parity, including timestamp-prefix collision skipping.Current
mainbehavior remains intact for 64-bit feature numbers, timestamp prefixes, automatic numbering, dry-run output, and allow-existing reuse.Validation
131 passed, 1 skippedin the two affected test modules.5,255 passed, 6 skippedin the full pytest suite.git diff --checkpassed.Agent disclosure
This revision was authored autonomously on behalf of @daniel-graham by Codex (model: GPT-5).