From 756226f6d15e37c93bbd6028572929f5edfeeb55 Mon Sep 17 00:00:00 2001 From: Ako Date: Sat, 26 Sep 2026 21:07:41 +0000 Subject: [PATCH 1/4] feat(mdl): alter microflow target resolver and describe ... with handles Start of mfmutator (mdl/backend/mfmutator), alongside pagemutator and wfmutator: a content-addressed target resolver over the stored microflow object collection (ADR-0012 decision 2, proposal item 4.2a). A target addresses an activity by output variable ($Lines), by caption ('Email is valid?'), or by statement pattern with * wildcards (commit $Order *), optionally with an @n ordinal. A target matching more than one activity is an error listing each match with its ordinal; the resolver never guesses. Patterns match the statement as describe prints it and as it is stored, since describe negates an if whose then-branch is empty. describe microflow M.X with handles prints "-- handle: " above each activity. The handles are comments; removing them leaves the plain description (tested as a control). Tested on Studio Pro-authored FeedbackModule.VAL_Feedback via MXCLI_PEDAPP_MPR until the PedApp fixture lands (#703). Refs #713, #714 Co-Authored-By: Claude Opus 5.5 --- cmd/mxcli/lsp_completions_gen.go | 1 + cmd/mxcli/syntax/features_microflow.go | 31 ++ docs/01-project/MDL_QUICK_REFERENCE.md | 1 + mdl/ast/ast_query.go | 5 + mdl/backend/mfmutator/resolve.go | 192 +++++++++ mdl/backend/mfmutator/target.go | 382 ++++++++++++++++++ mdl/backend/mfmutator/target_test.go | 268 ++++++++++++ mdl/backend/mfmutator/tokens.go | 159 ++++++++ mdl/executor/cmd_microflows_handles.go | 140 +++++++ .../cmd_microflows_handles_pedapp_test.go | 235 +++++++++++ mdl/executor/cmd_microflows_handles_test.go | 211 ++++++++++ mdl/executor/cmd_microflows_show.go | 51 ++- mdl/executor/executor_query.go | 2 +- mdl/grammar/MDLLexer.g4 | 4 + mdl/grammar/domains/MDLCatalog.g4 | 2 +- mdl/grammar/domains/MDLSettings.g4 | 1 + mdl/visitor/visitor_query.go | 7 +- 17 files changed, 1679 insertions(+), 13 deletions(-) create mode 100644 mdl/backend/mfmutator/resolve.go create mode 100644 mdl/backend/mfmutator/target.go create mode 100644 mdl/backend/mfmutator/target_test.go create mode 100644 mdl/backend/mfmutator/tokens.go create mode 100644 mdl/executor/cmd_microflows_handles.go create mode 100644 mdl/executor/cmd_microflows_handles_pedapp_test.go create mode 100644 mdl/executor/cmd_microflows_handles_test.go diff --git a/cmd/mxcli/lsp_completions_gen.go b/cmd/mxcli/lsp_completions_gen.go index 5904ebce8..739fd48d8 100644 --- a/cmd/mxcli/lsp_completions_gen.go +++ b/cmd/mxcli/lsp_completions_gen.go @@ -30,6 +30,7 @@ var mdlGeneratedKeywords = []protocol.CompletionItem{ {Label: "MODIFY", Kind: protocol.CompletionItemKindKeyword, Detail: "DDL keyword"}, {Label: "MERGE", Kind: protocol.CompletionItemKindKeyword, Detail: "DDL keyword"}, {Label: "NORMALIZED", Kind: protocol.CompletionItemKindKeyword, Detail: "DDL keyword"}, + {Label: "HANDLES", Kind: protocol.CompletionItemKindKeyword, Detail: "DDL keyword"}, {Label: "ENTITY", Kind: protocol.CompletionItemKindKeyword, Detail: "DDL keyword"}, {Label: "PERSISTENT", Kind: protocol.CompletionItemKindKeyword, Detail: "DDL keyword"}, {Label: "VIEW", Kind: protocol.CompletionItemKindKeyword, Detail: "DDL keyword"}, diff --git a/cmd/mxcli/syntax/features_microflow.go b/cmd/mxcli/syntax/features_microflow.go index 92618abde..bc7dc3a74 100644 --- a/cmd/mxcli/syntax/features_microflow.go +++ b/cmd/mxcli/syntax/features_microflow.go @@ -248,6 +248,37 @@ func init() { SeeAlso: []string{"microflow.merge-join", "microflow.control-flow"}, }) + Register(SyntaxFeature{ + Path: "microflow.describe-handles", + Summary: "DESCRIBE MICROFLOW ... WITH HANDLES: print each activity's content address", + Keywords: []string{ + "handles", "handle", "describe", "target", "address", "alter microflow", + "ordinal", "content addressing", "wildcard", + }, + Syntax: "DESCRIBE MICROFLOW Module.Name WITH HANDLES;\n\n" + + "-- Prints '-- handle: ' above each activity: the address that\n" + + "-- selects it in an ALTER MICROFLOW target (ADR-0012). Activities have no\n" + + "-- names, so a target names one by content, in this order of preference:\n" + + "-- $Var the activity whose output variable is $Var\n" + + "-- 'Caption' a split, or an activity with a custom caption\n" + + "-- commit $Order a statement pattern; * matches any run of\n" + + "-- log * node 'Debug' * tokens, and the pattern spans the WHOLE\n" + + "-- statement (end with * to match a prefix)\n" + + "-- A target matching several activities is an error that lists each with\n" + + "-- its ordinal (@1, @2, ... in describe order); it is never a guess.\n" + + "-- The handles are comments, so the output still executes unchanged.\n" + + "-- Cannot be combined with NORMALIZED, whose graph is not the stored one.", + Example: "DESCRIBE MICROFLOW FeedbackModule.VAL_Feedback WITH HANDLES;\n\n" + + "-- emits, among others:\n" + + "-- -- handle: $IsValidEmail\n" + + "-- $IsValidEmail = call java action FeedbackModule.ValidateEmail(...);\n" + + "-- -- handle: 'Email is Valid?'\n" + + "-- if not($IsValidEmail) then\n" + + "-- -- handle: set $ValidFeedback = false @3\n" + + "-- set $ValidFeedback = false;", + SeeAlso: []string{"microflow.normalized-describe"}, + }) + Register(SyntaxFeature{ Path: "microflow.merge-join", Summary: "Named join points: MERGE