Skip to content

fix(plan): reject date-prefixed slugs reserved for archives - #97

Merged
vipentti merged 3 commits into
mainfrom
fm/planlet-reject-date-slugs
Aug 25, 2026
Merged

fix(plan): reject date-prefixed slugs reserved for archives#97
vipentti merged 3 commits into
mainfrom
fm/planlet-reject-date-slugs

Conversation

@vipentti

@vipentti vipentti commented Aug 25, 2026

Copy link
Copy Markdown
Owner

Summary

Reject date-prefixed slugs at create time so new active slugs cannot collide with archive naming (plans/completed/<YYYY-MM-DD>-<slug>/), while keeping all existing date-prefixed planlets fully readable and operable.

  • Creation-only reservation: new assertCreatableSlug (used by createPlanlet) rejects a YYYY-MM-DD- prefix with a dedicated invalid_slug error and next guidance: Slugs must not start with a date (YYYY-MM-DD-); that prefix is reserved for archived plans under plans/completed/.
  • isValidSlug / assertValidSlug / parseArchiveName stay backward compatible: legacy active planlets with date-prefixed logical slugs remain targetable, updatable, and completable, and legacy archives whose logical slug itself is date-prefixed remain parseable and readable.
  • CHANGELOG.md ([Unreleased]), planlet_design.md, and AGENTS.md document the creation-only restriction and legacy compatibility.

Tests

  • tests/unit/slugs.test.ts: creation-rejection cases for real date prefix (2026-08-25-my-plan), invalid date-shape prefix (2026-99-99-foo), archive-date prefix (2024-02-29-cli-core); valid non-date slug (my-2026-plan / cli-2024-01-01 / a-2026-08-25) stays accepted; persistent isValidSlug unchanged
  • tests/integration/creation.test.ts: create-command-level test for date-prefix rejection and non-date acceptance, rejection before plans/ is created
  • tests/integration/legacy-date-prefix.test.ts: focused compatibility coverage - one legacy active date-prefixed slug updates and completes, one legacy date-prefixed archive remains readable, new creation rejects the prefix

Verification

  • npm run build green
  • npm test green (253 pass, 1 pre-existing packaging failure on main due to npm allow-scripts)
  • npm run lint green, npm run format:check green after npm run format
  • Manual: node dist/planlet.mjs --root $TMP create 2026-08-25-my-plan -> invalid_slug with date next; 2026-99-99-foo same; my-2026-plan succeeds

isValidSlug now rejects YYYY-MM-DD- prefix so active slugs cannot collide
with archive naming (plans/completed/<date>-<slug>). assertValidSlug
surfaces dedicated next guidance for date prefix. Add unit and
creation integration tests for valid/invalid date prefixes and non-date
slug acceptance.
…ility

Move date-prefix check from global isValidSlug/assertValidSlug to
creation-only assertCreatableSlug/isCreatableSlug so pre-existing
active and completed planlets with date-prefixed logical slugs remain
readable, validatable, task-updatable and completable. parseArchiveName
still uses isValidSlug so legacy archives like 2026-09-01-2026-08-25-my-plan
stay parseable. createPlanlet now calls assertCreatableSlug. Add
CHANGELOG Unreleased entry, update planlet_design.md and AGENTS.md to
distinguish persistent slug syntax from new-creation reservation, and
add unit + integration regression tests for legacy readability and
completion.
Drop unused isCreatableSlug predicate; tests assertCreatableSlug
directly. Keep isValidSlug for persistent storage and
assertCreatableSlug for creation policy.

Trim legacy-date-prefix suite to focused coverage: one legacy
active updates and completes, one legacy archive stays readable,
and creation rejects YYYY-MM-DD- prefix.
@vipentti
vipentti marked this pull request as ready for review August 25, 2026 07:15
@vipentti
vipentti merged commit 795b07c into main Aug 25, 2026
6 checks passed
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.

1 participant