fix(archive): treat early-synced REMOVED deltas as no-ops, plus audit follow-ups#1437
Conversation
… follow-ups Follow-ups from the post-v1.6.0 full-branch audit: - archive: a REMOVED delta whose requirement is already gone from the main spec (early-sync pattern) now warns and continues instead of aborting, matching the ADDED (#1376) and RENAMED (#1386) escapes; spec-update totals now count applied removals only - archive: the has-delta-specs gate matches section headers case-insensitively like the parser, so lowercase headers get the same delta validation errors validate reports - discovery: a symlinked specs/<cap>/spec.md is resolved instead of being invisible (hasAnyFileUnder and the artifact graph already counted it); dangling links are skipped - show: a plain `openspec show <change>` no longer warns about the never-passed `scenarios` flag (commander defaults --no-scenarios to true) - parsers: buildCodeFenceMask now has a single implementation in code-fence.ts; requirement-text.ts re-exports it - templates: apply/update/onboard no longer dead-end core-profile users on /opsx:continue and /opsx:new - they name the CLI fallback (openspec status/instructions) for profiles that do not install those workflows - qwen/bob: command bodies and skills reference commands by the hyphen names their files actually answer to (/opsx-<id>), matching opencode/pi/oh-my-pi - specs-apply: remove the dead applySpecs export (no callers, bypassed store-aware roots) Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (7)
🚧 Files skipped from review as they are similar to previous changes (4)
📝 WalkthroughWalkthroughThe PR refines archive delta validation and warning propagation, adds hyphenated command handling for additional tools, supports symlinked spec discovery, corrects explicit flag warnings, relocates code-fence masking, and updates installation-aware workflow guidance. ChangesCore behavior and workflow guidance
Estimated code review effort: 4 (Complex) | ~45 minutes Possibly related issues
Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 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: 2
🤖 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 `@src/core/templates/workflows/apply-change.ts`:
- Line 53: Preserve selected store context in all blocked-state and update
fallback command examples by appending the conditional --store <id> flag only
when store selection exists, while leaving local-root examples unchanged. Apply
this consistently at src/core/templates/workflows/apply-change.ts lines 53 and
213, skills/openspec-apply-change/SKILL.md line 51,
src/core/templates/workflows/update-change.ts lines 87-88 and 174-175, and
skills/openspec-update-change/SKILL.md line 86.
In `@src/core/templates/workflows/onboard.ts`:
- Line 516: Add a CLI recovery fallback next to the /opsx:continue guidance in
src/core/templates/workflows/onboard.ts at lines 516-516, describing openspec
status --change "<name>" --json and openspec instructions <artifact-id> --change
"<name>" --json, then regenerate the committed skill content and parity hash.
Mirror the same fallback in skills/openspec-onboard/SKILL.md at lines 506-506;
both sites require the guidance update.
🪄 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 Plus
Run ID: 4cb877b6-4150-4e85-85d1-59a9b1af62cb
📒 Files selected for processing (19)
skills/openspec-apply-change/SKILL.mdskills/openspec-onboard/SKILL.mdskills/openspec-update-change/SKILL.mdsrc/commands/show.tssrc/core/archive.tssrc/core/command-generation/adapters/qwen.tssrc/core/parsers/requirement-text.tssrc/core/specs-apply.tssrc/core/templates/workflows/apply-change.tssrc/core/templates/workflows/onboard.tssrc/core/templates/workflows/update-change.tssrc/utils/command-references.tssrc/utils/spec-discovery.tstest/commands/show.test.tstest/core/archive.test.tstest/core/command-generation/adapters.test.tstest/core/templates/skill-templates-parity.test.tstest/utils/command-references.test.tstest/utils/spec-discovery.test.ts
…, skip no-op writes Adversarial-review round for #1437: - a delta that both RENAMEs and REMOVEs the same requirement is rejected explicitly by both validate and archive - the warn-and-continue REMOVED path would otherwise have masked the contradiction that previously failed incidentally at apply time - buildUpdatedSpec collects its warnings and archive --json carries them in a new optional `warnings` array, so agent flows see the same skipped-REMOVED signal humans get on stdout - archive skips rewriting a spec whose operations were all already synced, instead of churning normalization differences into the file (and no longer materializes an empty skeleton for a REMOVED-only new spec) - init's getting-started hint uses each tool's real invocation form (/opsx-propose for qwen/bob/opencode/pi/oh-my-pi) - onboard's pause guidance names the CLI fallback when /opsx:continue is not installed (CodeRabbit) - openspec-conventions spec updated to state the idempotent archive semantics; changeset added Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 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 @.changeset/archive-early-synced-removed.md:
- Line 5: Update the wording in the changeset description to use the grammatical
form “Qwen- and Bob-generated files” instead of “qwen and bob generated files,”
preserving the rest of the description unchanged.
In `@src/core/archive.ts`:
- Around line 523-537: The archive update flow around writeUpdatedSpec must
track whether at least one file was actually written. Set specsUpdated and emit
the “Specs updated successfully” output only when writeUpdatedSpec runs, while
preserving zero-count skips and accurate JSON results for already-synced
changes.
In `@test/core/archive.test.ts`:
- Line 483: Remove the duplicate block-scoped logCalls declarations, retaining
only one declaration in test/core/archive.test.ts at lines 483-483 and one in
test/core/init.test.ts at lines 1071-1071; preserve each test’s existing use of
the retained constant.
🪄 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 Plus
Run ID: a65afc04-76c1-42e6-b1e6-84b275edea03
📒 Files selected for processing (12)
.changeset/archive-early-synced-removed.mdopenspec/specs/openspec-conventions/spec.mdskills/openspec-onboard/SKILL.mdsrc/core/archive.tssrc/core/init.tssrc/core/specs-apply.tssrc/core/templates/workflows/onboard.tssrc/core/validation/validator.tstest/core/archive.test.tstest/core/init.test.tstest/core/templates/skill-templates-parity.test.tstest/core/validation.test.ts
🚧 Files skipped from review as they are similar to previous changes (3)
- src/core/templates/workflows/onboard.ts
- test/core/templates/skill-templates-parity.test.ts
- src/core/specs-apply.ts
…or no-op archives Round-2 adversarial review for #1437: - a REMOVED header that differs only in case or interior whitespace from an existing requirement is a typo, not an early sync - it stays a hard abort naming the near-miss, instead of degrading to warn-and-continue - specsUpdated is true only when a spec file was actually written; a fully-already-synced change prints "Specs already in sync; no files changed." and reports specsUpdated: false in JSON (CodeRabbit) - agent-contract documents the archive warnings field and specsUpdated semantics; changeset wording fixed (CodeRabbit) Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Deploying openspec-docs with
|
| Latest commit: |
74a1026
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://9ea2eb5f.openspec-docs.pages.dev |
| Branch Preview URL: | https://audit-followups.openspec-docs.pages.dev |
alfred-openspec
left a comment
There was a problem hiding this comment.
The new conflict guard still misses case/whitespace variants: RENAMED FROM: Old Name plus REMOVED: old name passes validate --strict --json, then archive exits 0, renames the requirement, reports the removal as already synced, and archives the change. Please use the same case/whitespace-folded identity for the RENAMED+REMOVED cross-section check in both validation and apply, with focused regressions for both paths.
…ce-insensitively Addresses alfred's review on #1437: `RENAMED FROM: Old Name` plus `REMOVED: old name` slipped past the exact-match cross-section guard, so validate passed, archive renamed the requirement, reported the removal as already synced, and archived the change. Both the validator and the apply-side guard now compare the two spellings with the shared foldRequirementName (lowercase, collapsed whitespace), and the error names the variant spelling when it differs. Focused regressions cover both paths; requirement matching everywhere else stays case-sensitive. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
@alfred-openspec Fixed in 33ebba5. Both the validator and the apply-side guard now compare the RENAMED FROM header against REMOVED entries with a shared case- and whitespace-insensitive fold ( Your exact scenario, re-run against the built CLI:
Focused regressions for both paths: |
alfred-openspec
left a comment
There was a problem hiding this comment.
The follow-up closes the case/whitespace conflict gap in both validation and apply. I reproduced the original failure against the built CLI, confirmed both paths now fail safely without mutation, and the full 2,253-test suite passes at head 33ebba5.
Status: LGTM — full suite green (112 files / 2,251 tests, 14 new), lint clean, all 36 in-repo specs validate, every fix verified end-to-end against the built CLI. Hardened by two rounds of three independent adversarial reviews each, plus CodeRabbit; all confirmed findings addressed (details below).
What was wrong: a full audit of v1.6.0..main found no regressions, but a handful of pre-existing gaps — one workflow-blocking, the rest paper cuts:
REMOVED failed ... not found), while ADDED (#1376) and RENAMED (#1386) got already-synced escapes. The sync skill steers users straight into this.- 2 removednext to "2 ignored").## ADDED Requirementscase-sensitively while the parser is case-insensitive, so lowercase headers skipped delta validation and failed later with a worse error.specs/<cap>/spec.mdwas invisible todiscoverSpecFilesbut counted as content byhasAnyFileUnderand the artifact graph — archive would silently drop the delta.openspec show <change>printedWarning: Ignoring flags not applicable to change: scenarios(commander defaults--no-scenariostoscenarios: true).buildCodeFenceMaskexisted twice (#1151 added a second copy); both claimed to be the single source of truth./opsx:continueand/opsx:new, which core never installs (#1410 fixed only the init hints)./opsx:*, but their command files answer to/opsx-<id>— every cross-reference pointed at a nonexistent command.applySpecsexport with zero callers that bypassed store-aware roots.How it was fixed:
treating it as already removed) — analogous to the ADDED/RENAMED escapes, but with a warning since, unlike RENAMED, there is no signal separating early-sync from a typo. Totals count applied removals only. A missing MODIFIED target still aborts./i, so lowercase headers get the samevalidateChangeDeltaSpecserrors validate shows.spec.mdentries (dangling links skipped, other errors still thrown); symlinked directories remain unfollowed, as before.showcountsscenariosas user-provided only when it isfalse.buildCodeFenceMasklives incode-fence.ts;requirement-text.tsre-exports it (no import-site churn)./opsx:continue//opsx:newsuggestions but name the CLI fallback (openspec status --change/openspec instructions) for profiles that don't install them; onboard's extra-command tables say "only if installed."init --tools qwen,boboutput has zero/opsx:references left.applySpecsdeleted (not reachable from the public entry point).Adversarial-review round (second commit): three independent reviews (core logic, generation/templates, tests/compat) plus CodeRabbit produced these additional fixes, each with tests:
validateandarchive— previously it failed incidentally at apply time, and the new warn-and-continue path would have masked it.archive --jsoncarries spec-merge warnings in a new optionalwarningsarray, so agent flows see the skipped-REMOVED signal (previously the silent path swallowed it entirely — including for typos)./opsx-proposefor qwen/bob/opencode/pi/oh-my-pi,/skill:openspec-proposefor Kimi)./opsx:continueisn't installed (CodeRabbit).openspec-conventions/spec.mdupdated to state the idempotent archive semantics (direct spec edit, same precedent as fix(archive): keep the delta spec's Purpose in a new main spec #1431 — this also fixes the clause that fix(archive): stop failing on specs that were already synced before archiving #1376's idempotent-ADDED already contradicted), and a changeset was added.Round-2 review (third commit): a second set of three adversarial reviews on the updated diff (second-round-delta, fresh-eyes with a mandatory attack set, and consumers/contract) all returned merge-safe, and produced two more hardening fixes: a REMOVED header that differs only in case or interior whitespace from an existing requirement now stays a hard abort naming the near-miss (a fold-insensitive match present in the spec means typo, not early-sync), and
specsUpdatedis true only when a spec file was actually written — a fully-already-synced change printsSpecs already in sync; no files changed.and reportsspecsUpdated: falsewith its skips inwarnings(CodeRabbit). The reviews also verified: no template or skill parses archive output, the deleted exports were never publicly reachable (exportsmap blocks deep imports, so the patch bump is right), CRLF deltas work through the new paths, error paths never leak partial warnings arrays, and all parity hashes were independently recomputed.Replication / proof: repro before the fix — sync a REMOVED delta to the main spec, then
openspec archive <change>→REMOVED failed for header ... - not found, exit 1. After: archives with the warning, honest+0/−0totals, and the main spec byte-untouched (verified live and pinned by test). New tests cover each fix: early-synced REMOVED (human + JSON), applied-only counts, RENAMED+REMOVED conflict (validate + archive), lowercase-header gate parity, symlinked/danglingspec.md, default vs explicit--no-scenarios, qwen hyphen transform, transformer selection, and the per-tool init hint. Parity hashes andskills/regenerated via the documented recipe.Notes / nits:
/opsx:cross-reference pattern; each tool's invocation convention needs individual verification, so this PR only fixes the two with a documentedopsx-<id>surface (and matching in-repo precedent). Codex reference rewriting stays parked, per the existing comment.🤖 Generated with Claude Code
Summary by CodeRabbit
spec.mdfiles and ignores dangling symlinks.openspec show --jsonscenario warnings now respect explicit--no-scenarios.openspec archivenow preserves non-fatal warnings in output, avoids unnecessary rewrites, and treats early-synced removals as warnings.--jsoncontract to reflect optional command availability and warning output.