Skip to content

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

Open
mc856 wants to merge 3 commits into
Fission-AI:mainfrom
mc856:fix/archive-date-prefix-dedup
Open

fix(archive): keep an existing date prefix instead of stacking a new one#1316
mc856 wants to merge 3 commits into
Fission-AI:mainfrom
mc856:fix/archive-date-prefix-dedup

Conversation

@mc856

@mc856 mc856 commented Jul 7, 2026

Copy link
Copy Markdown

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 additional YYYY-MM-DD- prefix when the provided change name already includes one, preventing incorrect archive folder names and sorting.
  • Documentation
    • Updated the “Performing archive” instructions and rationale to clarify that fully date-prefixed names are preserved as-is, while others receive the current YYYY-MM-DD- prefix.
  • Tests
    • Added regression coverage for both full YYYY-MM-DD- and partial date-prefix change-name inputs to verify correct archive folder naming behavior.

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 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: f45179d3-1bcb-4e3f-9165-d1130fbe51a3

📥 Commits

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

📒 Files selected for processing (2)
  • src/core/archive.ts
  • test/core/archive.test.ts
🚧 Files skipped from review as they are similar to previous changes (2)
  • test/core/archive.test.ts
  • src/core/archive.ts

📝 Walkthrough

Walkthrough

Updates archive naming so an already date-prefixed change name is not prefixed again, and synchronizes the specification, regression tests, and changeset with that behavior.

Changes

Archive Date Prefix Dedup

Layer / File(s) Summary
Archive naming logic and regression tests
src/core/archive.ts, test/core/archive.test.ts
Adds date-prefix detection, preserves fully prefixed change names during archiving, and tests full-prefix 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

Suggested reviewers: tabishb

🚥 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 summarizes the main fix: preserving an existing date prefix in archive names 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

Warning

Tools execution failed with the following error:

Failed to run tools: 14 UNAVAILABLE: read ECONNRESET


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.

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)

1 participant