fix(validate): report requirements outside delta sections - #1804
fix(validate): report requirements outside delta sections#1804dwin-gharibi wants to merge 2 commits into
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Team Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
Included review availability: Your plan provides up to 10 included reviews per hour; 8 remain after this review. 📝 WalkthroughWalkthroughThe parser detects canonical requirement blocks outside the four delta sections. Apply and validation flows report these blocks as warnings with their location, while leaving them unapplied. ChangesOrphaned requirement handling
Estimated code review effort: 3 (Moderate) | ~20 minutes Merge Risk: ⚪ Minimal · up to The change adds diagnostics for misplaced requirement blocks while preserving their unapplied behavior. No concrete merge-blocking risk is currently identified. Sequence Diagram(s)sequenceDiagram
participant DeltaSpec
participant Parser
participant ApplyOrValidator
DeltaSpec->>Parser: parse requirement blocks
Parser->>Parser: detect blocks outside delta sections
Parser-->>ApplyOrValidator: return orphanedRequirements
ApplyOrValidator->>ApplyOrValidator: emit warning
ApplyOrValidator->>ApplyOrValidator: leave orphaned requirement unapplied
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ 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 |
alfred-openspec
left a comment
There was a problem hiding this comment.
Reviewed parser, validation, and archive behavior and ran the focused 11-test suite locally. Warning-only reporting closes the silent-drop gap without breaking legacy archived changes. Approved.
Closes #1803.
Why
The delta reader only looks inside the four delta sections. A canonical
### Requirement:block written anywhere else — under## Notes, under amisspelled
## Add Requirements, or above the first##header — is droppedwith no error, no warning and no note.
That is inconsistent with the treatment of the adjacent mistake. A
non-canonical
###header inside a delta section has been recorded inskippedHeadersand surfaced as INFO byvalidate <change>since #498. Thewell-formed requirement in the wrong place — arguably the costlier error,
because the block reads exactly like one that would apply — said nothing at all.
validatereports the change valid andarchiveexits 0.What Changes
parseDeltaSpecreturnsDeltaPlan.orphanedRequirements: every canonical### Requirement:header outside the delta sections, with the section it sitsunder (
nullabove the first##) and its 1-based line number.validate <change>reports each one as a WARNING naming the section andthe line, and listing the four headers it could move under.
buildUpdatedSpecemits the same thing through its existingwarn()channel,so
archivesays it too — the last point at which the author can still notice.Behaviour is otherwise unchanged: the orphan is still not applied. This PR
only ends the silence.
WARNING rather than ERROR is deliberate. Scanning every delta
spec.mdin thisrepository with its own parser found 8 blocks of this shape, all in archived
pre-format changes from 2025-08-19 (
add-skip-specs-archive-option,structured-spec-format). An ERROR would retroactively fail those; the fix for areal occurrence is to move the block, not to reject the change.
Testing
test/core/parsers/orphaned-requirements.test.ts— 11 tests, written first andwatched fail (10 failed / 1 passed before, 11 passed after).
Edge cases covered:
## Notes, under a misspelled## Add Requirements, and abovethe first
##section## Purpose(new capability) is notreported
buildUpdatedSpecwarns, and still does not apply the orphanvalidatereports it as a WARNING and the verdict stays valid (no ERROR)Full suite green on this branch.
Changeset
Not added. Per
.changeset/README.mdthe default path is the normal releasecadence; happy to run
pnpm changesetif a maintainer wants dedicated releasenotes.
Summary by CodeRabbit
New Features
Bug Fixes