Skip to content

feat: preserve sequence flow anchor sides across DESCRIBE roundtrip #275

@hjotha

Description

@hjotha

Problem

Studio Pro renders each SequenceFlow against one of four sides of the origin and destination activity boxes — top, right, bottom, left. mxcli currently discards this information in two places:

  1. The builder always derives the anchor side from the flow's visual direction (right→left for horizontal, right→bottom for downward returns, etc.).
  2. The describer drops the OriginConnectionIndex / DestinationConnectionIndex BSON fields entirely from the DESCRIBE output — no way to represent them in MDL.

Concrete impact on agentic workflows: when an agent generates an MDL patch for a microflow and mxcli exec applies it, the flow diagram in Studio Pro reshuffles arrow sides even when the agent's patch is semantically identical to the original. Reviewers complain that arrows now enter a box from the left when the original entered from the top — a low-signal but high-nuisance diff for any human touch-up.

Real example, against the Control Centre project:

  • Original Apps.GetOrCreateMendixVersionFromString had from: bottom, to: top on a vertical branch flow.
  • Describe → agent edits → exec reconstructed it as from: right, to: left.
  • 115 similar drifts across the project after a single round of fixes.

Proposed syntax

Optional annotation on microflow statements. When omitted, existing behaviour (builder chooses) is unchanged:

@anchor(from: right, to: left)
log info node 'App' 'hello';

Each side is independently optional. IF statements support a combined form for the incoming flow plus the per-branch outgoing flows:

@anchor(to: top, true: (from: right, to: left), false: (from: bottom, to: top))
if condition then
    ...
else
    ...
end if;

Sides: top (0), right (1), bottom (2), left (3) — matching the BSON connection-index values.

Describer policy

Always emit @anchor(...) for every activity with attached flows, so describe → exec → describe is bit-exact on the anchor indices. Split activities use the combined form above.

Why this is safe to add now

  • Existing MDL scripts don't have @anchor(...) → builder falls back to direction-derived default → zero behavioural change.
  • Lexer keywords are additive (anchor, top, bottom; left / right / from / to already exist).
  • Grammar change is scoped to the existing annotation rule + one new anchorSide production.
  • No BSON schema change — the bits we now preserve were already in the original BSON, just dropped in transit.

Implementation plan

I have a working branch at hjotha/submit/sequence-flow-anchor-annotation with the feature implemented end-to-end: AST fields, grammar, visitor, builder, describer, and tests. E2E verified against Control Centre (Mendix 9.24, ~200 microflows) on 5 representative cases including the attempt repro — the describe → exec → describe round-trip preserves every anchor (0 drifts) and the output parses through mxcli check.

PR to follow.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions