fix(concerto-linter): lint reserved system concept declarations#1237
Conversation
Signed-off-by: Rishabh Jain <rishabhj2005@email.com>
|
Hi @mttrbrts , I’ve implemented the linter follow-up for this. What changed:
A couple of related updates were needed as part of this:
This keeps |
There was a problem hiding this comment.
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 namedConcept,Asset,Transaction,Participant,Eventin legacy/v3, and in v4 when the dangerous flag is enabled. - Extends
lintModelto acceptdangerouslyAllowReservedSystemTypeNamesInUserModelsand injects that flag into the loaded Spectral ruleset. - Updates documentation and adjusts
no-reserved-keywordsbehavior/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. |
Signed-off-by: Rishabh Jain <rishabhj2005@email.com>
|
This PR is stale because it has been open with no activity. Remove the stale label or comment to keep it active. Only items with maintainer engagement are auto-closed. |
|
This PR is stale because it has been open with no activity. Remove the stale label or comment to keep it active. Only items with maintainer engagement are auto-closed. |
|
Hi @mttrbrts, kindly look into the pr when you have the time. Thanks! |
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
reserved-system-concept-declarationsdefault-ruleset rule forConcept,Asset,Transaction,Participant, andEvent, including support for legacy/v3 detection and dangerous-mode v4 linting.lintModelto acceptdangerouslyAllowReservedSystemTypeNamesInUserModels, inject that flag into the loaded ruleset, update docs, and add unit/integration coverage for the new behavior and theno-reserved-keywordsregression path.Flags
dangerouslyAllowReservedSystemTypeNamesInUserModelsis enabled.no-reserved-keywordsno 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
--signoffoption of git commit.mainfromRishabh060105:issue-1216-reserved-system-concept-lint