Skip to content

fix(config): stop warning about rules keys that belong to another schema#1377

Merged
clay-good merged 1 commit into
mainfrom
fix/config-rules-cross-schema
Jul 17, 2026
Merged

fix(config): stop warning about rules keys that belong to another schema#1377
clay-good merged 1 commit into
mainfrom
fix/config-rules-cross-schema

Conversation

@clay-good

Copy link
Copy Markdown
Collaborator

Status: Ready for review. Surgical fix, verified end-to-end.

What was wrong

openspec/config.yaml has a single global rules: map keyed by artifact ID, but each change can use a different schema. The validation only checked keys against the schema of the change currently being loaded, so any rules key that's legitimate for a different schema printed:

Unknown artifact ID in rules: "issue". Valid IDs for schema "spec-driven": design, proposal, specs, tasks

on every command in a multi-schema project (e.g. spec-driven for features + a lighter schema for fixes). The warning was pure noise — rules are applied per-artifact (rules?.[artifactId]), so a cross-schema key is simply unused for that change; nothing was ever misapplied.

How it's fixed

Validate rules keys against the union of artifact IDs across every available schema (built-in, user, and project-local) via the existing listSchemasWithInfo(). A key now warns only when it matches no artifact in any schema; keys valid for another schema are silent. The warning message drops its single-schema framing accordingly.

Two files, ~15 lines:

  • src/core/artifact-graph/instruction-loader.ts — build the valid-ID set from all schemas instead of just context.graph.
  • src/core/project-config.tsvalidateConfigRules no longer takes a schemaName; message reworded to "matches no artifact in any available schema."

Replication / proof

Repro: a project with a project-local light schema (artifact issue) + schema: spec-driven, and a rules: map containing issue. Before this change, loading any spec-driven change warns about issue.

End-to-end after the fix (temp project, real dist/):

schemas seen: light, spec-driven
union IDs: design, issue, proposal, specs, tasks
warnings (1):
  - Unknown artifact ID in rules: "totally-bogus". It matches no artifact in any available schema. Known artifact IDs: design, issue, proposal, specs, tasks

issue (valid only in light) no longer warns; a genuinely-unknown key (totally-bogus) still does.

New regression test in test/core/project-config.test.ts covers the union case. npm run build green; full suite passes (only the 17 documented environment-only zsh-installer tests fail locally, CI unaffected).

Notes

  • No config format, output format, or CLI change. Behavior change is limited to which keys warn.
  • The schemaName parameter of validateConfigRules was unused after this change and removed; the one caller and unit tests are updated.

Fixes #1322.

🤖 Generated with Claude Code

The global rules: map is validated against only the current change's schema,
so a key valid for a different schema prints a spurious "Unknown artifact ID"
warning on every command in multi-schema projects. Validate against the union
of artifact IDs across all available schemas; warn only when a key matches no
schema.

Fixes #1322.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@clay-good
clay-good requested a review from TabishB as a code owner July 16, 2026 22:26
@coderabbitai

coderabbitai Bot commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

Note

Currently processing new changes in this PR. This may take a few minutes, please wait...

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: dbbe9f53-d166-4ada-b675-7015f1bd531a

📥 Commits

Reviewing files that changed from the base of the PR and between 0a99f41 and 8762b13.

📒 Files selected for processing (4)
  • .changeset/config-rules-cross-schema.md
  • src/core/artifact-graph/instruction-loader.ts
  • src/core/project-config.ts
  • test/core/project-config.test.ts
 _______________________________________________________
< Perhaps loot boxes can help us cover the OpenAI bill. >
 -------------------------------------------------------
  \
   \   \
        \ /\
        ( )
      .( o ).
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/config-rules-cross-schema

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 commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Currently processing new changes in this PR. This may take a few minutes, please wait...

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: dbbe9f53-d166-4ada-b675-7015f1bd531a

📥 Commits

Reviewing files that changed from the base of the PR and between 0a99f41 and 8762b13.

📒 Files selected for processing (4)
  • .changeset/config-rules-cross-schema.md
  • src/core/artifact-graph/instruction-loader.ts
  • src/core/project-config.ts
  • test/core/project-config.test.ts
 ___________________________________
< I like big bugs and I cannot lie. >
 -----------------------------------
  \
   \   (\__/)
       (•ㅅ•)
       /   づ
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/config-rules-cross-schema

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 commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Caution

Review failed

An error occurred during the review process. Please try again later.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/config-rules-cross-schema

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.

@clay-good
clay-good added this pull request to the merge queue Jul 17, 2026
Merged via the queue into main with commit 285dfd7 Jul 17, 2026
14 checks passed
@clay-good
clay-good deleted the fix/config-rules-cross-schema branch July 17, 2026 17:45
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.

Config rules validation warns about keys that belong to other schemas

2 participants