Repository navigation
fix: YAML anchors, aliases and numbers in model files survive a save (#157) - #158
Merged
Merged
Conversation
…157) - An alias inside a relationships: entry (role: *r) no longer blocks every save: the entry is read with its aliases resolved against the file. - Every alias in the file, not only those under managed keys, is kept as it reads before the save; one whose anchor the save rewrites, removes or moves after it is written out as the value it read, keeping its comment, so an unmanaged key never follows an edit and the save never fails with "Unresolved alias". - A number prints as the text it was written with (007, 1e3, .5, +1), and a scalar the reader already reads as the wanted value is left as written, so description: true is not quoted and a reused number settles in one save. - A plain value that becomes a map or list keeps the line's comment. - Move Relationships to Model Library leaves (and names) a model file whose relationships: list holds a YAML anchor or alias, rather than re-render it and drop the anchor. - A seeded randomised test covers anchors and aliases across managed, unmanaged and relationship keys (1500 files, edits, idempotence). - CHANGELOG: one Added section, stray blank line removed. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…e reader did not take as text (#157) Review findings on the #157 fix: - Keeping and settling every alias called Alias.resolve, which walks the whole document, once per alias: a save of a file with thousands of aliases took seconds to minutes. Both passes now resolve every alias in one walk. - A relationship entry's keys are read only as text, so `role: true` holds no role; the "already reads the same" check let a canvas role "true" leave the boolean in place and the edit was lost. Those keys must now match as text exactly. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #157
What was wrong
Model files are hand-edited YAML, and YAML lets a value be written once with an anchor (
&x) and reused with an alias (*x). Several save paths didn't handle that, and a save also rewrote text nobody changed:relationships:entry (role: *r) made every save of that model fail with "this relationship entry cannot be read".x-note: *g) silently followed a canvas edit of the anchored value, and clearing that value failed the save withUnresolved alias.description: *relsewhere read as empty.description: truewas rewritten as"true"on any save.007→7(ametavalue then read "7"),1e3→1e+3,.5→0.5,+1→1.meta: ~ # c) dropped the line's comment.Fix (
src/services/logicalModelService.ts,src/services/minimalEdits.ts)keepNumberTextcustom tags; a value changed bysetScalarValuehas no text left and prints as usual). A scalar the reader already reads as the wanted value is left as written, which replaces the old "pin to a quoted string" step.relationshipsRewriteLosesflags arelationships:list holding a YAML anchor or alias, so Move leaves the file for the user and names it ("comments, YAML anchors or entries ERD Studio cannot read").Tests
logicalModelService.test.ts,minimalEdits.test.ts,moveRelationshipsToLibrary.test.ts).logicalModelAliases.property.test.ts, seeded. It runs 1500 generated files with anchors and aliases over managed, unmanaged and relationship keys plus number-looking text, then 0–3 canvas edits. It asserts the save doesn't throw, the result parses, it reads back exactly as the model, unmanaged keys read unchanged, a no-edit save is byte-identical, and a second save is byte-identical.name: 007is now left as007(byte-identical), not quoted as"007".Also tidies the
## Unreleasedchangelog (one### Addedsection, stray blank line removed).Out of scope, seen while testing: a single save that both renames and reorders columns can't match the renamed column, so its unknown keys are rebuilt. The canvas never sends those together.
🤖 Generated with Claude Code