Skip to content

fix(archive): keep an existing date prefix instead of stacking a new one#1316

Merged
clay-good merged 1 commit into
Fission-AI:mainfrom
mc856:fix/archive-date-prefix-dedup
Jul 18, 2026
Merged

fix(archive): keep an existing date prefix instead of stacking a new one#1316
clay-good merged 1 commit into
Fission-AI:mainfrom
mc856:fix/archive-date-prefix-dedup

Conversation

@mc856

@mc856 mc856 commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

Summary

openspec archive unconditionally prepends today's date to the change name. A change already named with the common YYYY-MM-DD- convention comes out double-dated, and when archived on a later day the folder sorts under a day on which the change did not happen.

Reproduced in a clean sandbox against main: openspec archive 2026-07-04-voice-copilot-v1 --yesarchived as '2026-07-07-2026-07-04-voice-copilot-v1'.

Changes

  • Detect a full ^YYYY-MM-DD- prefix in ArchiveCommand and archive the change under its own name; names without one (including partial dates like 2026-07-feature) keep the current behavior. This also makes the naming idempotent, per the issue's expectation.
  • Nothing in src/ parses the date back out of archive folder names — the prefix only drives human chronological sorting — so keeping the original date is the minimal, non-breaking choice.
  • Updated the two openspec/specs/cli-archive/spec.md lines that describe target-name generation and the date-prefixing rationale to match (direct spec edits alongside src/ follow the precedent of fix: detect hidden requirements in main specs #966).
  • Added a patch changeset.

Testing

  • Two new cases in test/core/archive.test.ts: an existing-prefix name is archived as-is; a partial-date name (2026-07-feature) still gets today's prefix (asserted as a pattern to avoid a UTC-midnight race). The existing first case covers plain names.
  • vitest run: 1813 passed, 1 pre-existing environment-dependent failure in test/commands/workset.test.ts (fails identically on pristine main when a real claude binary is on PATH); eslint src/ 0 errors (1 pre-existing warning); tsc --noEmit and node build.js clean.
  • Manual sandbox: 2026-07-04-voice-copilot-v1 now archives under its own name; plain-feature archives as 2026-07-07-plain-feature.

Notes

  • Open question: an alternative was to replace an existing prefix with today's date. I went with keep-as-is because it's what archive prepends today's date without detecting an existing date prefix (name gets double-dated) #1309 asks for, it's idempotent, and it avoids the archived folder sorting under the wrong day; happy to switch if maintainers prefer archive-date semantics.
  • Adjacent same-class issue, deliberately not touched here: the agent workflow templates instruct a literal mv to archive/YYYY-MM-DD-<name> (src/core/templates/workflows/archive-change.ts:87,205, bulk-archive-change.ts:135,384, onboard.ts:450), so the opsx workflow path can still stack a prefix. Happy to file a follow-up issue.
  • Small semantic change: re-archiving a same-named date-prefixed change on a different day previously produced distinct folders; it now fails with "Archive already exists". That's arguably more correct (the spec's no-overwrite rationale), but it does touch the "prevents naming conflicts" reasoning — flagging for awareness.

Fixes #1309

Summary by CodeRabbit

  • Bug Fixes
    • Fixed openspec archive to avoid stacking an extra YYYY-MM-DD- prefix when the provided change name already begins with a full date prefix, preventing incorrect archive folder names and sorting.
  • Documentation
    • Updated the “Performing archive” steps and rationale to clarify the naming behavior for fully date-prefixed vs non-prefixed change names.
  • Tests
    • Added regression tests covering both full YYYY-MM-DD- and partial date-like prefixes to ensure the archive target folder name is generated correctly.

@mc856
mc856 requested a review from TabishB as a code owner July 7, 2026 03:47
@coderabbitai

coderabbitai Bot commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 3899ef4f-a1d3-481c-9cd2-02cb3d3a2290

📥 Commits

Reviewing files that changed from the base of the PR and between 952d4af and c9cdf5e.

📒 Files selected for processing (4)
  • .changeset/fix-archive-date-prefix-dedup.md
  • openspec/specs/cli-archive/spec.md
  • src/core/archive.ts
  • test/core/archive.test.ts
🚧 Files skipped from review as they are similar to previous changes (2)
  • openspec/specs/cli-archive/spec.md
  • .changeset/fix-archive-date-prefix-dedup.md

📝 Walkthrough

Walkthrough

Updates archive naming so fully date-prefixed change names are preserved, with corresponding specification updates, regression tests, and a patch changeset.

Changes

Archive Date Prefix Dedup

Layer / File(s) Summary
Archive naming logic and regression tests
src/core/archive.ts, test/core/archive.test.ts
Detects full date prefixes, preserves already-prefixed names, and tests full and partial prefix cases.
Spec docs and changeset
openspec/specs/cli-archive/spec.md, .changeset/fix-archive-date-prefix-dedup.md
Documents prefix preservation and records the archive bug fix as a patch release.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related issues

  • OpenSpec issue 1309: Directly covers preventing duplicate date prefixes in archive folder names.
  • OpenSpec issue 1317: Addresses related duplicate date-prefix behavior in workflow template instructions.

Possibly related PRs

Suggested reviewers: tabishb, alfred-openspec

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly describes the main archive behavior change: preserving an existing date prefix instead of adding another one.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Archiving unconditionally prepended today's date to the change name, so a
change already named with the common YYYY-MM-DD- convention came out
double-dated (2026-07-07-2026-07-04-voice-copilot-v1) — and when archived
on a later day, the folder sorted under a day on which the change did not
happen.

Detect a full YYYY-MM-DD- prefix and archive the change under its own name.
Names without one (including partial dates like 2026-07-feature) keep the
current behavior. This also makes the naming idempotent.

Nothing in src/ parses the date back out of archive folder names — the
prefix only drives human chronological sorting — so keeping the original
date is the minimal, non-breaking choice. The cli-archive spec wording is
updated to match.

Fixes Fission-AI#1309
@mc856
mc856 force-pushed the fix/archive-date-prefix-dedup branch from 952d4af to c9cdf5e Compare July 18, 2026 17:11

@alfred-openspec alfred-openspec left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verified at c9cdf5e: full and partial prefix behavior matches the cli-archive contract, the focused archive suite passes locally, and CI is green. The agent-workflow parity gap is separately tracked in #1317, so it does not block this CLI fix.

@clay-good
clay-good added this pull request to the merge queue Jul 18, 2026
Merged via the queue into Fission-AI:main with commit 9b70481 Jul 18, 2026
11 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.

archive prepends today's date without detecting an existing date prefix (name gets double-dated)

3 participants