Skip to content

fix(workflows): preserve nested spec paths - #1508

Merged
clay-good merged 5 commits into
Fission-AI:mainfrom
clay-good:codex/nested-spec-guidance
Aug 4, 2026
Merged

fix(workflows): preserve nested spec paths#1508
clay-good merged 5 commits into
Fission-AI:mainfrom
clay-good:codex/nested-spec-guidance

Conversation

@clay-good

@clay-good clay-good commented Aug 4, 2026

Copy link
Copy Markdown
Collaborator

Status

LGTM.

What was wrong

OpenSpec already discovers, validates, syncs, and archives nested capability paths such as identity/user-auth, but its generated workflow guidance still prescribed the flat-only path specs/<capability>/spec.md. Agents could therefore flatten an existing nested capability or create a delta in the wrong directory.

How it was fixed

  • Define <capability-path> consistently across the spec-driven schema and the propose, explore, onboard, sync, archive, and bulk-archive workflows.
  • Preserve the exact path of existing capabilities.
  • Let new capabilities follow the project's established organization, without forcing flat projects to add a domain level.
  • Key bulk-archive conflict detection and recorded decisions by the complete capability path, so identical leaf names in different domains remain distinct.
  • Require sync subset requests to copy absolute existingOutputPaths entries verbatim, and require all bulk-archive examples to carry complete capability paths instead of ambiguous leaf-name shorthand.
  • Update generated skills, diagnostics, docs, and canonical specs to use the same terminology.
  • Add parity and schema tests covering both flat and nested paths.

This changes guidance only. It does not change path resolution, storage, APIs, schema format, or runtime architecture.

Replication / proof

  • Verified current main already supports nested paths through recursive discovery, parsing, validation, sync, and archive coverage.
  • Fresh Claude Code and Cursor initialization generated 24 artifacts. All 16 spec-aware workflow files contained capability-path guidance, with 0 flat-only path references.
  • node build.js
  • eslint src/
  • Strict validation of openspec-conventions, cli-validate, and specs-sync-skill
  • 119 test files passed, 3,476 tests passed
  • 4 adversarial review rounds with 12 independent agents completed; all actionable findings were resolved
  • CodeRabbit's valid path-identity and shell-placeholder findings were resolved

Notes / nits

PR #660 also proposes hierarchical specs, but it is a broad, conflicting runtime/configuration implementation from before recursive support landed on main. This PR addresses only the remaining current-main guidance mismatch and does not adopt that PR's architecture.

The issue suggests making <domain>/<capability> mandatory. OpenSpec's current human documentation instead calls direct folders such as auth/ and payments/ domains. This PR fixes the real flattening bug without introducing a new mandatory directory level or reorganizing existing projects.

No changeset is included because this is a routine guidance and documentation correction.

Fixes #1459

Summary by CodeRabbit

  • Documentation

    • Clarified specification path conventions for nested capability directories.
    • Updated proposal, onboarding, synchronization, exploration, validation, and archive guidance.
    • Added rules to preserve existing paths and follow project organization.
  • Bug Fixes

    • Improved nested capability path handling across specification and archive workflows.
    • Preserved exact paths during synchronization and bulk archive operations.
  • Tests

    • Added coverage for nested path preservation, explicit path selection, flat layouts, and workflow template parity.

@clay-good
clay-good requested a review from a team as a code owner August 4, 2026 16:03
@clay-good
clay-good requested review from alfred-openspec and removed request for a team August 4, 2026 16:03
@coderabbitai

coderabbitai Bot commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 9f601fac-9886-43ac-8ad6-1753e9fa2703

📥 Commits

Reviewing files that changed from the base of the PR and between 8a3850d and 3a5ee27.

📒 Files selected for processing (26)
  • docs/opsx.md
  • docs/troubleshooting.md
  • docs/writing-specs.md
  • openspec/specs/cli-validate/spec.md
  • openspec/specs/openspec-conventions/spec.md
  • openspec/specs/specs-sync-skill/spec.md
  • schemas/spec-driven/schema.yaml
  • schemas/spec-driven/templates/proposal.md
  • skills/openspec-archive-change/SKILL.md
  • skills/openspec-bulk-archive-change/SKILL.md
  • skills/openspec-explore/SKILL.md
  • skills/openspec-onboard/SKILL.md
  • skills/openspec-propose/SKILL.md
  • skills/openspec-sync-specs/SKILL.md
  • src/core/parsers/spec-structure.ts
  • src/core/templates/workflows/archive-change.ts
  • src/core/templates/workflows/bulk-archive-change.ts
  • src/core/templates/workflows/explore.ts
  • src/core/templates/workflows/onboard.ts
  • src/core/templates/workflows/propose.ts
  • src/core/templates/workflows/sync-specs.ts
  • src/core/validation/validator.ts
  • test/core/artifact-graph/instruction-loader.test.ts
  • test/core/artifact-graph/workflow.integration.test.ts
  • test/core/templates/skill-templates-parity.test.ts
  • test/core/validation.test.ts
🚧 Files skipped from review as they are similar to previous changes (23)
  • docs/opsx.md
  • test/core/validation.test.ts
  • schemas/spec-driven/schema.yaml
  • test/core/artifact-graph/workflow.integration.test.ts
  • src/core/templates/workflows/propose.ts
  • docs/troubleshooting.md
  • openspec/specs/specs-sync-skill/spec.md
  • test/core/artifact-graph/instruction-loader.test.ts
  • src/core/validation/validator.ts
  • openspec/specs/openspec-conventions/spec.md
  • src/core/templates/workflows/onboard.ts
  • src/core/templates/workflows/sync-specs.ts
  • src/core/parsers/spec-structure.ts
  • skills/openspec-archive-change/SKILL.md
  • openspec/specs/cli-validate/spec.md
  • src/core/templates/workflows/explore.ts
  • skills/openspec-onboard/SKILL.md
  • test/core/templates/skill-templates-parity.test.ts
  • src/core/templates/workflows/bulk-archive-change.ts
  • skills/openspec-sync-specs/SKILL.md
  • docs/writing-specs.md
  • src/core/templates/workflows/archive-change.ts
  • schemas/spec-driven/templates/proposal.md

📝 Walkthrough

Walkthrough

The change standardizes <capability-path> as a path relative to specs/. Schemas, documentation, workflow instructions, validation messages, and tests now support nested capability directories and preserve existing paths.

Changes

Nested capability path support

Layer / File(s) Summary
Capability path contracts and documentation
schemas/spec-driven/*, schemas/spec-driven/templates/*, openspec/specs/*, docs/*, skills/openspec-*/SKILL.md, src/core/templates/workflows/*
Guidance now defines <capability-path>, supports nested paths, and preserves existing capability organization.
Workflow path resolution
skills/openspec-*/SKILL.md, src/core/templates/workflows/*
Sync, propose, explore, onboard, archive, and bulk-archive workflows now preserve nested paths when resolving, creating, comparing, and verifying main specs.
Validation and diagnostics
src/core/parsers/spec-structure.ts, src/core/validation/validator.ts
Diagnostics now use capability-path terminology and nested path examples.
Path behavior and template parity tests
test/core/artifact-graph/*, test/core/templates/*, test/core/validation.test.ts
Tests verify nested-path guidance, path preservation, template parity, validation messages, and removal of legacy flat-path references.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Possibly related issues

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 summarizes the main change: preserving nested specification paths in workflow guidance.
Linked Issues check ✅ Passed The changes update agent instructions, templates, diagnostics, documentation, and tests to support nested capability paths while preserving existing project organization [#1459].
Out of Scope Changes check ✅ Passed All changes support the linked issue by updating guidance, diagnostics, canonical specifications, and related tests without modifying runtime behavior.
✨ 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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🧹 Nitpick comments (1)
src/core/templates/workflows/bulk-archive-change.ts (1)

20-21: 🗄️ Data Integrity & Integration | 🔵 Trivial | ⚡ Quick win

Key bulk-archive conflicts by the full capability path.

The new definition supports nested paths, but the conflict step at Line 88 still names the key capability and shows only leaf names. Define the key as the exact path relative to specs/. Otherwise identity/user-auth and billing/user-auth can collide by leaf name. Bulk archive can then apply an incorrect conflict decision or ordering to one delta.

Apply the wording to both template variants and regenerate skills/openspec-bulk-archive-change/SKILL.md.

Proposed wording
-   Build a map of `capability -> [changes that touch it]`:
+   Build a map of `<capability-path>` (the exact path relative to `specs/`) -> [changes that touch it]:

Please verify that conflict resolution uses this full path as its identity.

Based on learnings, committed skills/<skill-name>/SKILL.md files are generated output of scripts/generate-skillssh.mjs and must match generator output.

Also applies to: 359-360

🤖 Prompt for 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.

In `@src/core/templates/workflows/bulk-archive-change.ts` around lines 20 - 21,
Update both bulk-archive workflow template variants so conflict resolution keys
each delta by its full capability path relative to specs/, preserving nested
segments instead of using the leaf name or capability key. Ensure conflict
detection and ordering consistently use this path identity, then regenerate
skills/openspec-bulk-archive-change/SKILL.md with scripts/generate-skillssh.mjs.

Source: Learnings

🤖 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/specs/openspec-conventions/spec.md`:
- Line 227: Update the diff command in the command-line guidance to use the
defined <capability-path> placeholder consistently, replace the square-bracket
placeholders with angle-bracket placeholders, and quote both paths so shell
globbing cannot alter them before substitution.

In `@src/core/templates/workflows/explore.ts`:
- Around line 126-135: Synchronize the committed openspec-explore skill template
after the guidance change in the workflow template: regenerate
skills/openspec-explore/SKILL.md or update its parity hash using the project’s
established generator, so test/core/templates/skill-templates-parity.test.ts
matches the intentional content.

---

Nitpick comments:
In `@src/core/templates/workflows/bulk-archive-change.ts`:
- Around line 20-21: Update both bulk-archive workflow template variants so
conflict resolution keys each delta by its full capability path relative to
specs/, preserving nested segments instead of using the leaf name or capability
key. Ensure conflict detection and ordering consistently use this path identity,
then regenerate skills/openspec-bulk-archive-change/SKILL.md with
scripts/generate-skillssh.mjs.
🪄 Autofix

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: 361c9c3b-da5b-4e30-b6b6-6ee0af39f029

📥 Commits

Reviewing files that changed from the base of the PR and between 45cca5d and 93d2994.

📒 Files selected for processing (22)
  • docs/opsx.md
  • docs/troubleshooting.md
  • docs/writing-specs.md
  • openspec/specs/cli-validate/spec.md
  • openspec/specs/openspec-conventions/spec.md
  • openspec/specs/specs-sync-skill/spec.md
  • schemas/spec-driven/schema.yaml
  • schemas/spec-driven/templates/proposal.md
  • skills/openspec-archive-change/SKILL.md
  • skills/openspec-bulk-archive-change/SKILL.md
  • skills/openspec-explore/SKILL.md
  • skills/openspec-propose/SKILL.md
  • skills/openspec-sync-specs/SKILL.md
  • src/core/parsers/spec-structure.ts
  • src/core/templates/workflows/archive-change.ts
  • src/core/templates/workflows/bulk-archive-change.ts
  • src/core/templates/workflows/explore.ts
  • src/core/templates/workflows/propose.ts
  • src/core/templates/workflows/sync-specs.ts
  • src/core/validation/validator.ts
  • test/core/artifact-graph/workflow.integration.test.ts
  • test/core/templates/skill-templates-parity.test.ts

Comment thread openspec/specs/openspec-conventions/spec.md Outdated
Comment thread src/core/templates/workflows/explore.ts
alfred-openspec
alfred-openspec previously approved these changes Aug 4, 2026

@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.

Exact head cdeb9a7 is clean. Nested capability paths stay intact across schema guidance, generated workflows, sync/archive conflict identity, diagnostics, and docs; generated-skill parity, 86 focused tests, three strict living-spec validations, and the full hosted matrix all pass.

alfred-openspec
alfred-openspec previously approved these changes Aug 4, 2026

@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.

Exact head 57c1594 is clean. The follow-up clarifies capability-path inputs and preserves caller-supplied absolute output paths without regressing nested-path identity across propose, onboard, sync, archive, validation, or generated guidance. A fresh build and 128 focused workflow, validation, loader, and parity tests pass, with hosted CI green.

@coderabbitai

coderabbitai Bot commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

Note

GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer.

@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.

Re-reviewed the rebased head. Nested capability paths remain intact across schema guidance, generated workflows, conflict identity, validation, and diagnostics. A fresh build, 141 focused workflow/validation/loader/parity tests, strict validation of the three affected living specs, and the full hosted matrix pass.

@clay-good
clay-good added this pull request to the merge queue Aug 4, 2026
Merged via the queue into Fission-AI:main with commit 3d0701f Aug 4, 2026
13 checks passed
@clay-good
clay-good deleted the codex/nested-spec-guidance branch August 4, 2026 21:49
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.

Agent instructions don't organize specs by domain (flat <capability>/ layout instead of <domain>/<capability/>)

2 participants