Skip to content

Fix deployment metadata filters in view predicates#2986

Merged
davydkov merged 3 commits into
mainfrom
cgk/test-view-exclude-recipes
Jun 2, 2026
Merged

Fix deployment metadata filters in view predicates#2986
davydkov merged 3 commits into
mainfrom
cgk/test-view-exclude-recipes

Conversation

@ckeller42

@ckeller42 ckeller42 commented May 26, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Fix deployment relationship metadata filters so source.metadata.* and target.metadata.* use deployed instance metadata when present, with logical metadata as fallback.
  • Add focused coverage for metadata-based exclude rules in element and deployment views, including relationship metadata, endpoint metadata, arrays, and missing keys.
  • Update the user docs and the likec4-dsl AI skill/evals so agents explain relationship metadata filters and deployment metadata semantics correctly.

Root cause

Deployment model-backed relationship filters resolved endpoint metadata from the logical model element only, so deployment-specific instance metadata was ignored for source.metadata.* and target.metadata.* predicates.

Screenshots

View predicates docs

Before After
predicates-before.png predicates-after.png

Deployment views docs

Before After
deployment-before.png deployment-after.png

Validation

  • node_modules/.bin/vitest run packages/core/src/compute-view/element-view/exclude-where.spec.ts packages/core/src/compute-view/deployment-view/predicates/__test__/exclude-metadata.filter.spec.ts --no-isolate
  • node_modules/.bin/vitest run packages/core/src/compute-view/element-view packages/core/src/compute-view/deployment-view --no-isolate
  • node_modules/.bin/tsc -b packages/core/tsconfig.json --pretty false
  • node_modules/.bin/astro check from apps/docs
  • node_modules/.bin/nano-staged
  • node_modules/.bin/dprint check for the changed skills/likec4-dsl files
  • Skill eval sanity: 36 public/grading eval pairs matched, with no hidden grading fields leaked into evals-public.json
  • Matching external skill benchmark harness self-test passed for the likec4-dsl eval artifacts
  • Opened the updated docs pages locally and captured before/after screenshots

@changeset-bot

changeset-bot Bot commented May 26, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: b328eb4

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 22 packages
Name Type
@likec4/core Patch
@likec4/playground Patch
@likec4/config Patch
@likec4/diagram Patch
@likec4/generators Patch
@likec4/language-server Patch
@likec4/language-services Patch
@likec4/layouts Patch
@likec4/leanix-bridge Patch
@likec4/spa Patch
likec4 Patch
@likec4/mcp Patch
@likec4/react Patch
@likec4/vite-plugin Patch
@likec4/vscode-preview Patch
likec4-vscode Patch
@likec4/docs-astro Patch
@likec4/lsp Patch
@likec4/style-preset Patch
@likec4/styles Patch
@likec4/log Patch
@likec4/tsconfig Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@ckeller42 ckeller42 force-pushed the cgk/test-view-exclude-recipes branch from 857b3be to 069a11c Compare May 26, 2026 12:07
@ckeller42

Copy link
Copy Markdown
Collaborator Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented May 26, 2026

Copy link
Copy Markdown
Contributor
✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai

coderabbitai Bot commented May 26, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 54b13b38-8490-4bf3-af91-47d8e3629ccb

📥 Commits

Reviewing files that changed from the base of the PR and between e27913c and b328eb4.

📒 Files selected for processing (2)
  • packages/core/src/compute-view/deployment-view/predicates/__test__/exclude-metadata.filter.spec.ts
  • packages/core/src/compute-view/element-view/exclude-where.spec.ts
🚧 Files skipped from review as they are similar to previous changes (2)
  • packages/core/src/compute-view/deployment-view/predicates/test/exclude-metadata.filter.spec.ts
  • packages/core/src/compute-view/element-view/exclude-where.spec.ts

📝 Walkthrough

Walkthrough

This PR fixes deployment relationship metadata filtering so deployed-instance metadata replaces model element metadata when present, adds tests for deployment- and element-view exclude predicates covering instance/relationship/endpoint metadata and fallback rules, and updates documentation and skill/eval content with examples and clarifications.

Changes

Metadata predicates in deployment views

Layer / File(s) Summary
Metadata override in deployment predicate resolution
packages/core/src/compute-view/deployment-view/predicates/utils.ts, .changeset/fix-deployment-metadata-filters.md
toFilterable now uses deployed-instance metadata as an override with fallback to model element metadata; tags remain combined. Changeset entry documents the replacement-vs-merge semantic.
Deployment view metadata predicate tests
packages/core/src/compute-view/deployment-view/predicates/__test__/exclude-metadata.filter.spec.ts
New Vitest suite validates deployment-view exclude where behavior: exclusion by instance metadata, relationship metadata, participant-scoped endpoint selectors, fallback to logical metadata, and instance-metadata override when present.
Element view exclude-where predicate tests
packages/core/src/compute-view/element-view/exclude-where.spec.ts
Adds excludeWhere test helper and end-to-end tests for element-view exclude predicates: element exclusion by metadata (value/missing/array) and relationship exclusion by kind, relationship metadata, and source-participant metadata.
Documentation of metadata predicate behavior
apps/docs/src/content/docs/dsl/Deployment/views.mdx, apps/docs/src/content/docs/dsl/Views/predicates.mdx
Expanded filtering docs to detail metadata override rules and relationship endpoint metadata resolution in deployment views; added example exclude * -> * where target.metadata.zone is "restricted"; clarified that exclude supports the same metadata filters as include.
Skills, evals, and reference examples
skills/likec4-dsl/SKILL.md, skills/likec4-dsl/evals/*, skills/likec4-dsl/references/*
Adds Metadata predicates section, four new public evals and grading entries (IDs 32–35), and updates reference/example docs to include relationship/endpoint metadata examples, deployment metadata precedence guidance, and predicate usage notes.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • likec4/likec4#2576: Completed deployment-view $exclude predicate tests including participant-based relation exclusion in the same predicate test area.

Suggested reviewers

  • davydkov
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 25.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
Title check ✅ Passed The title accurately summarizes the main change: fixing deployment metadata filters in view predicates, which aligns with the core fix described in the PR.
Description check ✅ Passed The PR description comprehensively covers the summary, root cause, validation steps, and includes before/after screenshots. All key aspects of the changeset are explained.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ 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 cgk/test-view-exclude-recipes

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

ESLint skipped: no ESLint configuration detected in root package.json. To enable, add eslint to devDependencies.


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 and usage tips.

@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

🤖 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
`@packages/core/src/compute-view/deployment-view/predicates/__test__/exclude-metadata.filter.spec.ts`:
- Around line 1-4: The file exclude-metadata.filter.spec.ts currently has a
copyright header referencing "NVIDIA CORPORATION & AFFILIATES"; confirm whether
that is intentional for this repository and if not, replace the header with the
repository's standard copyright holder text (or the SPDX and year only) so the
top-of-file comment matches project convention; locate the header at the top of
exclude-metadata.filter.spec.ts and update the owner string accordingly.

In `@packages/core/src/compute-view/element-view/exclude-where.spec.ts`:
- Around line 1-4: The file header in exclude-where.spec.ts contains a copyright
line referencing "NVIDIA CORPORATION & AFFILIATES"; update this header to use
the repository's standard copyright holder (or the project's legal owner) so it
matches other files—edit the top-of-file comment block to replace "NVIDIA
CORPORATION & AFFILIATES" with the correct holder (e.g., the likec4 org or the
project's canonical copyright string) and ensure SPDX and year remain correct.
🪄 Autofix (Beta)

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: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 2c67584c-8b78-49f0-8416-f2c4b4adef6d

📥 Commits

Reviewing files that changed from the base of the PR and between c18fa00 and 069a11c.

📒 Files selected for processing (6)
  • .changeset/fix-deployment-metadata-filters.md
  • apps/docs/src/content/docs/dsl/Deployment/views.mdx
  • apps/docs/src/content/docs/dsl/Views/predicates.mdx
  • packages/core/src/compute-view/deployment-view/predicates/__test__/exclude-metadata.filter.spec.ts
  • packages/core/src/compute-view/deployment-view/predicates/utils.ts
  • packages/core/src/compute-view/element-view/exclude-where.spec.ts

Comment thread packages/core/src/compute-view/element-view/exclude-where.spec.ts
@ckeller42

Copy link
Copy Markdown
Collaborator Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented May 27, 2026

Copy link
Copy Markdown
Contributor
✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@ckeller42

Copy link
Copy Markdown
Collaborator Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented May 27, 2026

Copy link
Copy Markdown
Contributor
✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@ckeller42 ckeller42 marked this pull request as ready for review May 27, 2026 10:40
@ckeller42 ckeller42 requested a review from davydkov May 27, 2026 10:40
@davydkov davydkov merged commit 8ad28c7 into main Jun 2, 2026
18 checks passed
@davydkov davydkov deleted the cgk/test-view-exclude-recipes branch June 2, 2026 20:56
@likec4-ci likec4-ci Bot mentioned this pull request Jun 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