Skip to content

feat(vscode): instantiate items catalogues in the pattern picker - #3113

Open
YoofiTT96 wants to merge 12 commits into
finos:mainfrom
YoofiTT96:feat/2859-vscode-picker-items
Open

YoofiTT96 wants to merge 12 commits into
finos:mainfrom
YoofiTT96:feat/2859-vscode-picker-items

Conversation

@YoofiTT96

Copy link
Copy Markdown
Member

Description

A pattern may declare nodes and relationships under items as well as prefixItems. The VS Code pattern picker read only prefixItems, so choosing a pattern with a catalogue produced a starter architecture with the catalogue nodes missing and nothing said why.

The picker is a scaffold, not calm generate. It asks nothing, takes the first alternative wherever a pattern offers a choice, and fills unpinned strings with [[PLACEHOLDER]]. A catalogue now gets exactly that treatment, so one member lands on the canvas for the author to edit, copy or delete.

Part of #2859.

PR sequence

Five stacked PRs, each reviewable alone, in this order:

PR Scope
1 #3059 prefixItems alternatives — the pre-existing gaps that had to be fixed first
2 #3060 items in pattern validation
3 #3103 items in generation
4 #3110 items in the pattern diagram
5 this items in the VS Code pattern picker

GitHub will not let a cross-fork PR target a branch in my fork, so all of them sit on main and each diff carries the ones below it. The commit to review here is the last one.

The decision worth knowing

A catalogue counts as a declaration site only when it carries oneOf or anyOf. items applies one schema to every position after the entries, so a member declared directly there is not a choice and stays unread — the same line PATTERN-DECISIONS.md draws, and the same one validation, generation and the diagram already draw.

That leaves the change at one helper. instantiateNode already recurses into the first alternative, so a catalogue reuses the existing path rather than adding a second branch.

Why the move out of the JSX

vitest.config.ts sets environment: 'node', so the package cannot render a React component in a test, and instantiateFromPattern was module-private inside PatternPicker.tsx. It moves unchanged into pattern-instantiation.ts, matching the BuildingBlockCreator.tsx / building-block-doc.ts pair beside it. The move is most of the line count in the diff and changes no behaviour.

Gotcha

This makes a catalogue reachable from the picker; it does not add a decision UI. The picker still takes the first alternative of a prefixItems decision and of a catalogue, and it still scaffolds one catalogue member rather than several. That heuristic predates this PR and now applies at one more site.

Separately, the extension runs no pattern validation at all — it depends on @finos/calm-models and Ajv, not on @finos/calm-shared, and validateCalmArchitecture checks an architecture against the CALM meta-schema. The rules in #3060 reach the CLI and not the editor. That gap is older than #2859 and is not addressed here.

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.)

Additive. A pattern that uses no items scaffolds exactly as before.

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 ✅

feat(vscode): instantiate items catalogues in the pattern picker

Testing

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

Eight tests in a new pattern-instantiation.test.ts, the first tests this logic has had. They cover a positional entry, the first alternative of a prefixItems decision, a catalogue member landing after the positional entries, an anyOf catalogue, a catalogue relationship, an items block that declares a node directly, an items block that only holds a $ref, and an empty pattern.

Mutation-tested twice. Stop reading the catalogue and three of the eight fail. Drop the oneOf/anyOf guard and one fails.

Before the change, a pattern declaring gateway and a postgres/mysql decision positionally, with a cache/queue catalogue, scaffolded gateway and postgres only. It now also scaffolds cache.

calm-plugins/vscode passes 15 files and 163 tests. Lint reports 0 errors and 5 warnings, all pre-existing in other files. The extension builds clean.

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

🤖 Generated with Claude Code

@github-actions github-actions Bot added cli Affects `cli` code shared calm-hub-ui Affects `calm-hub-ui` labels Sep 15, 2026
A catalogue member was invisible to calm diff. Adding or removing one
reported no change at all, and hasChanges stayed false, so
calm diff --exit-code passed. An unchanged member appeared in no bucket,
so the Hub painted it with no diff status.

The catalogue is a choice block, so it is read as one more declaration
source and expandAlternatives flattens it into the existing partition.
Members land in the buckets that already exist. No new buckets, no change
to NodeChange or hasChanges.

An items schema that declares a node directly is not read, matching
validation and the pattern renderer.

The allOf traversal was written for prefixItems only, so it becomes
findField, which takes what the caller is after.

Reporting a change in obligation is out of scope and filed as finos#3111. It
reproduces on main with no items involved.
@YoofiTT96
YoofiTT96 marked this pull request as ready for review September 18, 2026 11:11
@YoofiTT96
YoofiTT96 requested a review from a team as a code owner September 18, 2026 11:11

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

calm-hub-ui Affects `calm-hub-ui` cli Affects `cli` code shared

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant