Skip to content

fix(core): use Structurizr DSL identifiers for element ids and patches - #411

Merged
parse merged 2 commits into
mainfrom
fix/structurizr-identifiers
Nov 18, 2026
Merged

parse merged 2 commits into
mainfrom
fix/structurizr-identifiers

Conversation

@parse

@parse parse commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

Stacked on #410.

What changed

  • Element ids: resolved from erode.id, then the structurizr.dsl.identifier property that the DSL parser writes for every element (structurizr/structurizr StructurizrDslParser.registerIdentifier), then an ASCII slug of the name. UUID identifiers from anonymous elements are ignored.
  • Numeric JSON ids ("1", "5") are only used internally to resolve relationship endpoints. They are never exposed or written to DSL. Before, real exports without erode.id produced ids like 1.5, and every patch failed validation.
  • Patches: relationship lines use DSL identifiers. Relationships to elements without one, and new components whose id is not a valid DSL identifier, are skipped with a reason instead of breaking the whole patch.
  • Element type: taken from the JSON array the element sits in (people, softwareSystems, containers, components), not guessed from the number of dots.
  • Duplicates: two elements resolving to the same id fail the load with an error naming both.
  • Internals: DSL references are passed to patcher hooks as an argument (no instance state); one DSL identifier pattern in common.schema.ts; derived state reset on every load; references map built once.
  • Docs: ADR-003 amendment; Structurizr page rewritten for id resolution, with a "Model patches" and an "Upgrading" section.

Behaviour changes (possibly breaking)

  • Exposed component ids change from numeric JSON ids to DSL identifiers (orders instead of 2.3). Users who set erode.id keep their ids.
  • Duplicate resolved ids, or a name with no usable ASCII characters and no DSL identifier, now fail the load. Set erode.id to resolve.
  • A JSON workspace with only erode.id and no DSL identifiers gets no relationship patches (skipped with a reason).

Review follow-ups

  • When every relationship is skipped, the skip reasons are printed instead of only a generic message (ModelPatchOptions.skipped).

Checks

Check Result
check:ci pass
knip pass
Tests 1154 core + 10 cli pass
Real Structurizr CLI export not run (no Java or Docker here); fixture mirrors the parser's output per upstream source and test resources

@coderabbitai

coderabbitai Bot commented Nov 17, 2026 •

Copy link
Copy Markdown

Explain Change →

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Warning

Some tools did not complete. Review the errors below.

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 install failed: one or more packages not found in the registry.

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

@parse
parse added this pull request to stack #414 November 17, 2026 17:21
@parse
parse force-pushed the fix/structurizr-identifiers branch from d3a08ff to 2fa96a9 Compare November 17, 2026 17:49
@parse
parse marked this pull request as ready for review November 17, 2026 17:49
@parse
parse requested a review from a team as a code owner November 17, 2026 17:49
@greptile-apps

greptile-apps Bot commented Nov 17, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; no new blocking issues were found.

Summary

Structurizr models now expose stable DSL identifiers instead of numeric JSON IDs, and relationship patches use the matching source identifiers.

  • Structurizr models now expose stable element IDs instead of JSON numbers.
  • Structurizr relationship patches now use DSL names and report skipped links.
  • LikeC4 patching now reads strings and comments safely and starts with model edits.

The previous finding about lost skip reasons is addressed: the caller now keeps and prints them when no patch remains. No new actionable issues were found.

Reviews (4) · Last reviewed commit: "fix(core): report skip reasons when no m..." · Reviewed by Greptile

@parse
parse force-pushed the fix/structurizr-identifiers branch 3 times, most recently from d547cf5 to c468291 Compare November 18, 2026 07:20
Base automatically changed from fix/likec4-patching-robustness to main November 18, 2026 07:22
- Element ids come from erode.id, then the structurizr.dsl.identifier
  property the DSL parser writes, then an ASCII slug of the name
- Numeric JSON ids stay internal and are never written to DSL
- Patches reference DSL identifiers; relationships to elements without
  one, and new components with invalid ids, are skipped with a reason
- Element type comes from the JSON array, not the id depth
- Duplicate resolved ids fail the load and name both elements
- ADR-003 amendment and an Upgrading note in the Structurizr docs
Callers can pass a skipped array in the patch options; analyze prints
the reasons when every relationship was skipped, so users see why, for
example that an element needs a DSL identifier.
@parse
parse force-pushed the fix/structurizr-identifiers branch from c468291 to f82642d Compare November 18, 2026 07:22
@parse
parse merged commit c146db1 into main Nov 18, 2026
9 checks passed
@parse
parse deleted the fix/structurizr-identifiers branch November 18, 2026 07:24
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.

1 participant