feat(microflows): expose the Commit flag on create/change activities (#779) — recovered from #67 - #71
Merged
Merged
Conversation
CommitType declared two values that do not exist in the Mendix metamodel: "YesWithEvents" and "NoEvent". The canonical set is Yes / YesWithoutEvents / No (modelsdk/gen/microflows CommitEnum, generated from Mendix reflection data, and docs/05-mdl-specification/10-bson-mapping.md). Nothing crashed, because the read path passes the stored string through untouched — but the named constants matched nothing in a real project, so any code switching on them fell through to its default. The giveaway was mdl/backend/mcp, whose mfCommitType had to translate CommitTypeNoEvent into "YesWithoutEvents" to produce a correct PED value, mapping a constant named "no events" onto "yes, without events". Replaces the set with the canonical three and simplifies mfCommitType, which no longer needs the translation. A new test pins CommitType against the generated CommitEnum in both directions, so neither a missing value nor an invented one can drift back in. Groundwork for mendixlabs#779 (exposing the flag in DESCRIBE MICROFLOW), which needs a trustworthy value set to render. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012XR649rKk68z6gBpngu6MA
…mendixlabs#779) MDL had no syntax for the Commit setting, and the builder hardcoded CommitTypeNo at both call sites. Every create/change authored through MDL was therefore written as Commit: No regardless of intent — and a describe → edit → re-exec round-trip silently turned committing activities into non-committing ones. That is a data-fidelity bug, not just a missing feature: it is exactly the object-orphaning failure mode mendixlabs#779 reports chasing in Studio Pro. Syntax follows the existing `refresh` modifier on change, spelling all three values of Mendix's Microflows$Commit enum: $Order = create Sales.Order (Number = 'X'); -- No (default) $Order = create Sales.Order (Number = 'X') commit; -- Yes $Order = create Sales.Order (Number = 'X') commit without events; change $Order (Status = 'Paid') commit refresh; The default stays unwritten, so existing scripts are unaffected and turning the flag on is a one-word diff. `COMMIT` both modifies a create/change and starts a standalone commit activity, so the two could be confused. Mandatory statement semicolons make it decidable: the modifier cannot absorb a following `commit $Var` across a terminator. Two tests pin that specifically — a create followed by a commit activity, and a create carrying the modifier AND followed by one. Wired grammar → AST (CommitFlag) → visitor (buildCommitClause) → builder (commitTypeOf). DESCRIBE emission is the next commit; until then the flag is authorable and persisted but not yet rendered. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012XR649rKk68z6gBpngu6MA
…abs#779) The reported symptom: DESCRIBE rendered a create/change activity with Commit enabled identically to one without, so transaction boundaries were invisible to automated analysis, linting and impact tooling — and confirming them meant opening Studio Pro activity by activity. The value was already read (both engines populate CreateObjectAction.Commit and ChangeObjectAction.Commit); the formatter simply never looked at it. It now renders the modifier introduced in the previous commit, omitting it for Mendix's default (No) so existing describe output is unchanged for the common case. Canonical order on change is `commit [without events]` then `refresh`, matching the grammar, so re-executing the output rebuilds the same activity. Round-trip is asserted rather than assumed: TestFormatAction_CommitRoundTrips formats each of the three values, re-parses the emitted MDL through the visitor, and requires the flag to come back identical — which is mendixlabs#779's second acceptance criterion. A formatter emitting syntax the grammar cannot read would be worse than not emitting it at all. Adds mdl-examples/doctype-tests/779-commit-flag.mdl covering all three values on both create and change, with and without member lists, and the modifier sitting next to a standalone COMMIT activity. Docs: MDL_QUICK_REFERENCE.md create/change rows, write-microflows.md CREATE and CHANGE sections, and the `microflow.object-operations` syntax topic — each distinguishing the modifier from the standalone COMMIT activity, which is the easy thing to confuse. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012XR649rKk68z6gBpngu6MA
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.
Fixes mendixlabs#779. Re-opens the content of #67, whose commits never reached
main.Why this PR exists
#67 was stacked on #66 (
claude/microflow-mandatory-semicolons). #66 merged intomainat00:34:26; #67 merged intoclaude/microflow-mandatory-semicolons17 seconds later, at00:34:43. Its base branch had already been merged, so the three commits landed on a branch that was no longer going anywhere —mainnever received them.GitHub retargets a stacked child PR to
mainonly when the base branch is deleted. The base still existed, so #67 kept pointing at it and merged there. Verified before opening this:The three commits are cherry-picked onto current
mainhere, unchanged in content. Worth deletingclaude/microflow-mandatory-semicolonsonce this lands, so the stranded copies can't be picked up again.What it does
mendixlabs#779 asks for the Commit flag to be visible in
DESCRIBE MICROFLOW. The larger half is that MDL had no syntax for it and the builder hardcoded it:So every create/change mxcli authored was written as
Commit: Noregardless of intent, and a describe → edit → re-exec round-trip silently converted committing activities into non-committing ones — the object-orphaning failure mode the reporter describes chasing in Studio Pro.68f290a—CommitTypedeclared"YesWithEvents"and"NoEvent", neither of which exists in the Mendix metamodel; the canonical set isYes/YesWithoutEvents/No. The giveaway wasmdl/backend/mcptranslatingCommitTypeNoEventinto"YesWithoutEvents"to stay correct. A test now pins the set against the generatedCommitEnumin both directions.d55832d— the syntax, following the existingrefreshmodifier:The default stays unwritten, so existing scripts are unaffected. Two tests pin the ambiguity against the standalone
commit $Varactivity — mandatory semicolons (#66, already onmain) are what make that decidable.50515be— DESCRIBE emission.TestFormatAction_CommitRoundTripsformats each value, re-parses the emitted MDL, and requires the flag back identical, which is mendixlabs#779's second acceptance criterion.Verification on current main
Parser regenerated, full Go suite green, example corpus at 236 / 39 — one more passing file than before, which is this PR's
779-commit-flag.mdl.🤖 Generated with Claude Code
https://claude.ai/code/session_012XR649rKk68z6gBpngu6MA
Generated by Claude Code