fix archive scenario drift for #1246#1252
Conversation
📝 WalkthroughWalkthroughA scenario-drift guard is added to the ChangesScenario Drift Guard for MODIFIED Archives
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related issues
Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@openspec/changes/fix-archive-modified-scenario-drift-1246/tasks.md`:
- Line 7: The remaining checklist item in the task list is still unchecked even
though the PR includes proposal/design/task docs, so update the task status to
match the actual scope. Adjust the checklist entry in tasks.md by either marking
it complete if it should remain, or removing/closing it if it is no longer
applicable; use the existing checklist item text “Commit only source and test
changes” as the anchor.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 763f8388-630b-4be8-a213-143a5ab6c9fa
📒 Files selected for processing (5)
openspec/changes/fix-archive-modified-scenario-drift-1246/design.mdopenspec/changes/fix-archive-modified-scenario-drift-1246/proposal.mdopenspec/changes/fix-archive-modified-scenario-drift-1246/tasks.mdsrc/core/specs-apply.tstest/core/archive.test.ts
alfred-openspec
left a comment
There was a problem hiding this comment.
PR #1252 Review: fix archive scenario drift for #1246
Date: 2026-06-25 05:20 AEST
Author: @zhangsan582
PR: #1252
Summary
This is directionally the right shape for #1246: archive-time conflict detection is safer than silently whole-block replacing a stale MODIFIED requirement. The implementation adds a missing-current-scenario guard before nameToBlock.set(key, mod), so the reported A-then-B scenario data-loss case is blocked before the canonical spec is rewritten.
Verification
- Checked PR metadata and diff.
- Read
src/core/specs-apply.tsandtest/core/archive.test.tschanges. - Ran targeted test on the PR branch:
pnpm exec vitest run test/core/archive.test.ts- Result: 25 passed.
Findings
Changes requested: committed OpenSpec change files should be removed
The PR includes:
openspec/changes/fix-archive-modified-scenario-drift-1246/design.mdopenspec/changes/fix-archive-modified-scenario-drift-1246/proposal.mdopenspec/changes/fix-archive-modified-scenario-drift-1246/tasks.md
The PR body says these were intentionally excluded from the commit, but GitHub shows them as committed. For a narrow external bug fix, these local planning artifacts should not merge into the main repo unless maintainers explicitly want this change proposal recorded there.
Notes
- The current guard detects scenario-heading loss, not all possible stale-base drift. It can still overwrite body edits for scenarios with the same heading. That is acceptable as a scoped fix for #1246 if we treat this as a first guardrail before a future fingerprint/semantic merge design.
- The regression test exercises the actual archive command path and verifies B remains unarchived after the abort, which is the right coverage for this bug class.
Review decision
Changes requested. Remove the committed openspec/changes/fix-archive-modified-scenario-drift-1246/ files, then this looks mergeable as a scoped #1246 guard.
|
thanks for catching that. I removed the mistakenly committed OpenSpec change files in the latest commit:
The remaining diff is limited to the archive guard and regression test for #1246. |
alfred-openspec
left a comment
There was a problem hiding this comment.
Thanks for cleaning that up. Re-reviewed the latest head c7e3800: the OpenSpec change docs are gone, the remaining diff is scoped to the archive guard and regression test, and pnpm exec vitest run test/core/archive.test.ts plus pnpm run lint both pass locally. Looks good to me as a scoped #1246 fix.
Fix: Issue #1246
When archiving two consecutive changes that both MODIFIED the same requirement, the later archive with an older baseline will no longer silently overwrite and delete the scenario added by the previous change.
Previously,
buildUpdatedSpecwould replace the entire block based on the requirement name. As a result, the second change with an older baseline would delete newly added scenarios from the canonical spec.This adds/changes/fixes archive-time drift protection: For MODIFIED blocks, it compares the
#### Scenario:sections between the current spec and the incoming block. If the current spec contains existing scenarios that are missing from the incoming block, the archive process aborts and prompts the user to refresh the change spec, preventing data loss.Changes
MODIFIEDscenario loss check tosrc/core/specs-apply.ts.test/core/archive.test.ts, covering the scenario where A archives first, and B's older baseline archive is aborted.openspec/changes/fix-archive-modified-scenario-drift-1246/, which is excluded from the commit.Verification
pnpm exec vitest run test/core/archive.test.tspassedpnpm exec vitest run test/core/archive.test.ts test/core/parsers/requirement-blocks.test.tspassedpnpm exec vitest run test/commands/validate.test.tspassedpnpm run lintpassedpnpm run buildpassedpnpm testwas executed, but unrelated e2e timeout/EBUSY errors occurred under Windows:test/cli-e2e/basic.test.tsand one temp directory cleanup intest/commands/validate.test.ts. Relevant tests passed when re-run individually.Commit
cc1ac37880a7284b97408e2dc6b611d3d9d46843fix archive scenario drift for #1246src/core/specs-apply.tsandtest/core/archive.test.ts, excluding OpenSpec-related files.Summary by CodeRabbit
Bug Fixes
MODIFIEDarchive operations from silently dropping existing scenarios.Documentation
Tests
Summary by CodeRabbit
Bug Fixes
Tests