Skip to content

mps-cli-py (binary-persistency): fix stream misalignment in cross-module model references#61

Merged
Prithvi686 merged 3 commits into
mainfrom
feature/E3AARCHAI-23402_fix_binary_persistence_parser_stream_misalignment_issue
Apr 27, 2026
Merged

mps-cli-py (binary-persistency): fix stream misalignment in cross-module model references#61
Prithvi686 merged 3 commits into
mainfrom
feature/E3AARCHAI-23402_fix_binary_persistence_parser_stream_misalignment_issue

Conversation

@Prithvi686
Copy link
Copy Markdown
Collaborator

@Prithvi686 Prithvi686 commented Apr 26, 2026

15 .mpb files in a big repository (migration.mpb, editor.mpb etc..) were failing to parse with read_bytes(18576): EOF warnings.

Root cause is that -
In _read_other_model_ref() in nodes.py, after reading a MODELID_REGULAR model id, the parser called read_string() but Java's ModelInputStream.readModelReference() calls readModuleReference() there instead.
This was never caught before because standard MPS plugin directories I guess uses MODELREF_INDEX for cross-model refs but the vemb repo's language plugins use full inline MODELID_REGULAR references hitting this path for the first time.

Fix:
Replace read_string() with _read_module_ref() in _read_other_model_ref() in nodes.py.

Result
zero parse warnings
Models read now: From 2624 to 2625
Nodes read now: From 11,176,926 to 11,179,666

… details of the issue and applied fix explained below:

- Our binary persistence parser was calling read_string() after reading a MODELID_REGULAR model id but Java's ModelInputStream.readModelReference()
calls readModuleReference() there  instead but this was missed earlier which caused stream misalignment issues.
- This issue wasn't caught earlier since In standard MPS plugin directories this code path is never reached because cross-model references use MODELREF_INDEX but the vemb repo's language plugins specifically  migration scripts etc..  most likely use full inline MODELID_REGULAR references which exposed this issue.

- Replaced read_string() with _read_module_ref() in _read_other_model_ref() in nodes.py.

Affected: 15 .mpb files (migration.mpb, editor.mpb etc..)
Result: From 2624 models to 2625 models parsed now and from 11,176,926 nodes to 11,179,666 nodes successfully parsed now without any issues.
Copy link
Copy Markdown

@ratiud ratiud left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

many thanks for this fix

lgtm

@Prithvi686 Prithvi686 merged commit 576c46b into main Apr 27, 2026
4 of 5 checks passed
@Prithvi686 Prithvi686 deleted the feature/E3AARCHAI-23402_fix_binary_persistence_parser_stream_misalignment_issue branch April 27, 2026 06:15
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