Skip to content

fix(concerto-linter): lint reserved system concept declarations#1237

Open
Rishabh060105 wants to merge 2 commits into
accordproject:mainfrom
Rishabh060105:Rishabh060105/issue-1216-reserved-system-concept-lint
Open

fix(concerto-linter): lint reserved system concept declarations#1237
Rishabh060105 wants to merge 2 commits into
accordproject:mainfrom
Rishabh060105:Rishabh060105/issue-1216-reserved-system-concept-lint

Conversation

@Rishabh060105
Copy link
Copy Markdown
Contributor

@Rishabh060105 Rishabh060105 commented May 25, 2026

Closes #1216

Adds a default Concerto linter rule that reports declaration names colliding with reserved system concepts in the risky compatibility contexts called out in the issue. Normal v4 linting stays silent, while legacy/v3 models and dangerous-mode v4 runs now surface actionable errors earlier.

Changes

  • Add a new reserved-system-concept-declarations default-ruleset rule for Concept, Asset, Transaction, Participant, and Event, including support for legacy/v3 detection and dangerous-mode v4 linting.
  • Extend lintModel to accept dangerouslyAllowReservedSystemTypeNamesInUserModels, inject that flag into the loaded ruleset, update docs, and add unit/integration coverage for the new behavior and the no-reserved-keywords regression path.

Flags

  • Normal v4 behavior is unchanged: this rule only reports for legacy/v3 models or when dangerouslyAllowReservedSystemTypeNamesInUserModels is enabled.
  • no-reserved-keywords no longer catches capitalized system concept names generically, so those names are now handled by the new targeted rule instead.

Screenshots or Video

N/A

Related Issues

Author Checklist

  • Ensure you provide a DCO sign-off for your commits using the --signoff option of git commit.
  • Vital features and changes captured in unit and/or integration tests
  • Commits messages follow AP format
  • Extend the documentation, if necessary
  • Merging to main from Rishabh060105:issue-1216-reserved-system-concept-lint

Signed-off-by: Rishabh Jain <rishabhj2005@email.com>
@Rishabh060105
Copy link
Copy Markdown
Contributor Author

Hi @mttrbrts , I’ve implemented the linter follow-up for this.

What changed:

  • Added a new default linter rule, reserved-system-concept-declarations, to flag declaration names that collide with reserved system concepts:
    • Concept
    • Asset
    • Transaction
    • Participant
    • Event
  • The rule reports in:
    • legacy / v3 model contexts
    • v4 only when dangerouslyAllowReservedSystemTypeNamesInUserModels is enabled
  • Normal v4 linting remains unchanged and stays silent.

A couple of related updates were needed as part of this:

  • Extended lintModel so it can accept dangerouslyAllowReservedSystemTypeNamesInUserModels and pass that into the loaded ruleset.
  • Adjusted no-reserved-keywords so capitalized system concept names are no longer caught by the generic keyword rule; they are now handled by the new targeted rule instead.
  • Added docs and test coverage for:
    • v3 / legacy invalid cases
    • dangerous-mode v4 invalid cases
    • normal v4 valid cases
    • regression coverage around no-reserved-keywords

This keeps #1215 as the core behavior change, and makes #1216 the linter-side early warning on top of it.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds a compatibility-aware default linter rule to catch user declarations that collide with reserved Concerto system concept names, surfacing actionable violations for legacy/v3 models and for v4 runs when the “dangerous” reserved-type-name opt-out is enabled.

Changes:

  • Introduces a new default-ruleset rule reserved-system-concept-declarations (with fixtures + tests) to flag declarations named Concept, Asset, Transaction, Participant, Event in legacy/v3, and in v4 when the dangerous flag is enabled.
  • Extends lintModel to accept dangerouslyAllowReservedSystemTypeNamesInUserModels and injects that flag into the loaded Spectral ruleset.
  • Updates documentation and adjusts no-reserved-keywords behavior/tests so capitalized system concept names are handled by the new targeted rule.

Reviewed changes

Copilot reviewed 16 out of 17 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
packages/concerto-linter/src/index.ts Adds dangerous-mode option to lintModel and patches ruleset to pass the flag into the reserved-system rule.
packages/concerto-linter/test/unit/lintModel.test.ts Unit tests for silent v4 behavior, dangerous-mode reporting, and custom-ruleset injection.
packages/concerto-linter/README.md Documents compatibility-aware linting via dangerouslyAllowReservedSystemTypeNamesInUserModels.
packages/concerto-linter/default-ruleset/src/ruleset-main.ts Registers the new reserved-system-concept-declarations rule in the default ruleset.
packages/concerto-linter/default-ruleset/src/reserved-system-concept-declarations.ts Defines the new rule entry (given/severity/then).
packages/concerto-linter/default-ruleset/src/functions/find-reserved-system-concept-declarations.ts Implements the rule function (legacy/v3 detection + dangerous-mode gating).
packages/concerto-linter/default-ruleset/src/no-reserved-keywords.ts Adjusts reserved keyword regex to stop catching capitalized system concept names generically.
packages/concerto-linter/default-ruleset/test/rules/reserved-system-concept-declarations.test.ts Adds rule-level tests for v3/legacy/v4 and dangerous-mode behavior.
packages/concerto-linter/default-ruleset/test/rules/no-reserved-keywords.test.ts Adds regression coverage ensuring system concepts aren’t reported by the generic keyword rule.
packages/concerto-linter/default-ruleset/test/fixtures/reserved-system-concept-declarations-v4-valid.cto Valid v4 fixture.
packages/concerto-linter/default-ruleset/test/fixtures/reserved-system-concept-declarations-v4-invalid.cto Invalid v4 fixture (reserved declarations).
packages/concerto-linter/default-ruleset/test/fixtures/reserved-system-concept-declarations-v3-invalid.cto Invalid v3 fixture (reserved declarations).
packages/concerto-linter/default-ruleset/test/fixtures/reserved-system-concept-declarations-legacy-invalid.cto Invalid legacy fixture (missing namespace version).
packages/concerto-linter/default-ruleset/test/fixtures/no-reserved-keywords-system-concepts-valid.cto Fixture ensuring the keyword rule doesn’t flag system concept names.
packages/concerto-linter/default-ruleset/README.md Documents the new rule and its compatibility-dependent behavior.
packages/concerto-linter/default-ruleset/package.json Adds semver dependency for parsing concerto version metadata.
package-lock.json Lockfile update for the new semver dependency.

Comment thread packages/concerto-linter/src/index.ts
Signed-off-by: Rishabh Jain <rishabhj2005@email.com>
@github-actions github-actions Bot added the maintainer-engaged A maintainer has commented or reviewed this item label May 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

maintainer-engaged A maintainer has commented or reviewed this item

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(concerto-linter): rule to flag system concept declarations in v3 and when dangerous opt-out is enabled in v4

3 participants