Skip to content

fix: exclusive mkdir so concurrent create-new-feature cannot overwrite spec.md - #4310

Open
BetterAndBetterII wants to merge 1 commit into
github:mainfrom
BetterAndBetterII:fix/atomic-feature-dir-reserve
Open

fix: exclusive mkdir so concurrent create-new-feature cannot overwrite spec.md#4310
BetterAndBetterII wants to merge 1 commit into
github:mainfrom
BetterAndBetterII:fix/atomic-feature-dir-reserve

Conversation

@BetterAndBetterII

Copy link
Copy Markdown

Problem

create-new-feature picks the next sequential spec number, checks that FEATURE_DIR is absent, then creates it with mkdir -p (bash), New-Item -Force (PowerShell), or Path.mkdir(exist_ok=True) (Python). Those creates are not exclusive.

Two concurrent invocations can therefore scan the same max number, both pass the exists check, both create the same directory, and the second write clobbers spec.md.

Fix

Create FEATURE_DIR exclusively. On EEXIST, rescan specs/ for the next sequential number and retry before writing spec.md. Timestamp mode still errors on collision, matching the previous exists-check behavior.

Fixes #4270

Reserve FEATURE_DIR with exclusive mkdir so a lost race rescans instead of clobbering spec.md.
Copilot AI balanced review requested due to automatic review settings August 25, 2026 10:29

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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

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.

[Bug]: create-new-feature.sh reserves feature numbers non-atomically — concurrent invocations can share/overwrite a spec directory

2 participants