Repository navigation
fix(scripts): force base 10 in get_next_project_number (#762) - #764
Merged
Merged
Conversation
`get_next_project_number` compared a zero-padded directory prefix inside an arithmetic context, where bash reads a leading 0 as octal. 008 and 009 are invalid octal, so the comparison errored and was skipped; 010 and 011 were silently read as decimal 8 and 9. max_num never reached the true maximum, so from the eighth project onward the function returned a number that already existed. The failing ((...)) sits in an `if` condition, where errexit is suspended, so create-project.sh printed two stderr lines, created a second 010- project over the top of an existing one via `mkdir -p`, and still reported "success": true with exit 0. 48 commands invoke scripts/bash/create-project.sh and all six extensions that ship bash scripts carried the same copy, so this was the default path. The Python implementation was always correct, which meant the two script sets disagreed on any repo past seven projects. Adds tests/plugin/test_project_numbering.py: allocation across both bash copies for seven through twelve projects, silence on stderr, bash/Python parity, and the reported collision end-to-end. Seven is covered deliberately as the last count the octal arithmetic got right. Reported-by: @chrismckelt Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VKbHCujejpxkgvh47BndDE
This was referenced Aug 13, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #762.
The bug
get_next_project_numberin bothcommon.shcopies compared the zero-padded directory prefix inside an arithmetic context, where bash reads a leading0as octal.008and009are invalid octal, so the comparison errored and was skipped;010and011were silently read as decimal 8 and 9.max_numnever reached the true maximum, so from the eighth project onward the function returned a number that already existed.Reproduced exactly as reported, in a repo with
000-globalplus001–011:projects/010-p010already existed. Result: two010-directories, a README and a full set ofARC-010-*artefact paths under the wrong project ID, exit 0.The failing
((...))sits in anifcondition, whereerrexitis suspended, soset -euo pipefaildid not catch it andcreate_project_dir's baremkdir -pdid not treat the existing target as an error. This is the second distinct way this same function has failed quietly underset -e, after thefindinteraction documented atcreate-project.sh:70.Verified impact, matching the report row for row:
001–007008008(correct)001–008008009001–009008010001–010009011001–011010012001–012011013Blast radius
Larger than the report states. 48 commands invoke
scripts/bash/create-project.sh, and all six extensions that ship bash scripts (codex,gemini,opencode,copilot,vibe,kimi) carried the same copy, so the broken path was the default one. The Python implementation inscripts/python/common.pyand the JSnextSequenceingenerate-document-id.mjswere both always correct, which meant the two script sets disagreed on any repo past seven projects.The fix
Force base 10 at the capture site in both copies, as suggested in the issue. Extension copies are converter output and were regenerated.
Tests
New
tests/plugin/test_project_numbering.py:create-project.shlands on a fresh directory and leaves no duplicate prefixSeven projects is covered deliberately: it is the last count the octal arithmetic got right, so a future rewrite cannot fix the tail by breaking the head.
Confirmed RED before the fix (24 failed, 4 passed, the 4 being the
007cases), GREEN after (28 passed). Full suite: 1325 passed / 225 skipped, plus 285 node tests,sync-shared-assets.py --checkclean, markdownlint clean.Not included
Two items deliberately left out of this PR, both worth their own issue:
create_project_dirrefuse an existing target is sound and safe (I checked:create-project.shhas no--number, no reuse path, and only ever creates), but it is a behaviour change beyond the reported defect.common.shcopies, unrelated to this bug.find_repo_rootlooks for.arckit/in the root copy andprojects/in the plugin copy, andslugifydiverges on accented input:"Café Modernisation"becomescafé-modernisationunder one copy andcaf-modernisationunder the other.tests/plugin/test_repo_audit.pyenforces byte-identity for the twocreate-project.shcopies but there is no equivalent guard forcommon.sh, and one cannot be added while these differences stand.Thanks to @chrismckelt for a report that pinned the mechanism, the trigger threshold and the fix precisely.
🤖 Generated with Claude Code
https://claude.ai/code/session_01VKbHCujejpxkgvh47BndDE