Skip to content

fix(shared): validate singular interface field in connects relationships#26

Draft
Copilot wants to merge 3 commits intomainfrom
copilot/work-on-issue-1993
Draft

fix(shared): validate singular interface field in connects relationships#26
Copilot wants to merge 3 commits intomainfrom
copilot/work-on-issue-1993

Conversation

Copy link

Copilot AI commented Mar 2, 2026

Description

calm validate silently accepted references to non-existent interfaces in connects relationships when using the singular "interface": "string" form. The Spectral rules only validated the plural "interfaces": [] array form, but all real-world architecture files (including the canonical calm-1.json/calm-2.json) use the singular form — making interface validation a no-op in practice.

Root cause: interfaceIdExistsOnNode short-circuited on !input.interfaces, so singular interface strings were never checked. No Spectral rule targeted the singular field path.

Changes

  • interface-id-exists-on-node.ts — collects desired interfaces from both interface (string) and interfaces (array) before validating against the target node; previously bailed out if interfaces was absent
  • rules-architecture.ts — adds referenced-interface-defined-in-architecture rule targeting $.relationships[*].relationship-type.connects.*.interface (singular path) via existing interfaceIdExists function
  • interface-id-exists-on-node.spec.ts — adds 4 tests covering singular interface: valid reference, interface not on target node, and target node with no interfaces

Before (no error reported):

{
  "connects": {
    "source": { "node": "node-a" },
    "destination": { "node": "node-b", "interface": "non-existent-interface" }
  }
}

After:

Referenced interface with ID 'non-existent-interface' was not defined on the node with ID 'node-b'.

Type of Change

  • 🐛 Bug fix (non-breaking change which fixes an issue)
  • ✨ New feature (non-breaking change which adds functionality)
  • 💥 Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • 📚 Documentation update
  • 🎨 Code style/formatting changes
  • ♻️ Refactoring (no functional changes)
  • ⚡ Performance improvements
  • ✅ Test additions or updates
  • 🔧 Chore (maintenance, dependencies, CI, etc.)

Affected Components

  • CLI (cli/)
  • Schema (calm/)
  • CALM AI (calm-ai/)
  • CALM Hub (calm-hub/)
  • CALM Hub UI (calm-hub-ui/)
  • CALM Server (calm-server/)
  • CALM Widgets (calm-widgets/)
  • Documentation (docs/)
  • Shared (shared/)
  • VS Code Extension (calm-plugins/vscode/)
  • Dependencies
  • CI/CD

Commit Message Format ✅

Testing

  • I have tested my changes locally
  • I have added/updated unit tests
  • All existing tests pass

Checklist

  • My commits follow the conventional commit format
  • I have updated documentation if necessary
  • I have added tests for my changes (if applicable)
  • My changes follow the project's coding standards

💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

…and plural forms

Co-authored-by: rocketstack-matt <66839492+rocketstack-matt@users.noreply.github.com>
Copilot AI changed the title [WIP] Address issue 1993 in architecture-as-code fix(shared): validate interfaces in connects relationships for singular and plural forms Mar 2, 2026
Co-authored-by: rocketstack-matt <66839492+rocketstack-matt@users.noreply.github.com>
Copilot AI changed the title fix(shared): validate interfaces in connects relationships for singular and plural forms fix(shared): validate singular interface field in connects relationships Mar 2, 2026
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.

2 participants