Skip to content

feat: collision-resistant ID allocation on new (--id, --base) - #24

Merged
budhash merged 1 commit into
mainfrom
feature/id-allocation
Jul 16, 2026
Merged

budhash merged 1 commit into
mainfrom
feature/id-allocation

Conversation

@budhash

@budhash budhash commented Jul 16, 2026

Copy link
Copy Markdown
Owner

Closes #13 — the prevention leg of the multi-branch ID-collision incident (renumber in v1.3.0 is the cleanup leg).

What

  • new … --id T-42 — create with an explicit ID (short forms normalized like all ID input). Refused if the ID is already taken (primary or @shadow) or the kind doesn't match. No --force — a forced duplicate ID is file corruption in every case; deviation from the triage sketch recorded in the design doc.
  • new … --base <git-ref> — auto-allocate max(local, ref) + 1 by reading TASKS.md at the ref (git rev-parse --show-toplevel + git show ref:path, fence-skipping scan same as local). A branch forked from main can no longer re-issue IDs main already handed out.
  • Fails closed: any git problem (no repo, bad ref, file absent at ref, tasks file outside the repo) is a hard error — a silent fallback to local-only allocation would quietly reintroduce the collisions the flag exists to prevent. (Contrast: renumber --refs degrades gracefully because it's a best-effort report, not a safety guarantee.)
  • --id + --base compose — the explicit ID must be free at the ref too.
  • reserve N stays deferred (needs persisted reservation state — a new format concept).

Compatibility

Both flags are opt-in; new without them is byte-identical behavior. No file-format change (schema.md untouched).

Testing

TDD: e2e scenarios 53 (--id + guards) and 54 (--base incident-shape allocation, --id+--base ref-collision refusal, fail-closed on bad ref and outside git) written first and watched fail (Unknown arg: --id). Suite now 298 assertions, green on make check.

Design doc

docs/superpowers/specs/2026-07-15-id-allocation-design.md (in this PR). LEARNINGS.md entry included.

https://claude.ai/code/session_01UquRBmRrh52iyPFuFQna5q

Closes #13 — the prevention leg of the multi-branch ID-collision
incident (renumber in 1.3.0 is the cleanup leg):

- new --id T-42: create with an explicit ID (normalized like all ID
  input). Refused if taken (primary or @shadow) or cross-kind; no
  --force — a forced duplicate ID is corruption, not a feature.
- new --base <git-ref>: allocate max(local, ref) + 1 by reading
  TASKS.md at the ref (git show), so a branch forked from main cannot
  re-issue IDs main already handed out. Fails closed on any git
  problem instead of silently falling back to local-only allocation.
  With --id, the explicit ID must be free at the ref too.
- reserve N stays deferred (would add a new concept to the format).

Design doc: docs/superpowers/specs/2026-07-15-id-allocation-design.md
e2e scenarios 53-54 (13 new assertions, suite now 298).

Claude-Session: https://claude.ai/code/session_01UquRBmRrh52iyPFuFQna5q
@budhash
budhash merged commit 97dc350 into main Jul 16, 2026
5 checks passed
@budhash
budhash deleted the feature/id-allocation branch July 16, 2026 06:18
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.

Feature: collision-resistant ID allocation (ref-aware / explicit --id / reserve)

1 participant