Skip to content

fix(executor): a bare System enumeration in a flow signature is an enumeration - #1544

Merged
ako merged 1 commit into
mainfrom
fix/mcp-system-enum-param
Oct 21, 2026
Merged

ako merged 1 commit into
mainfrom
fix/mcp-system-enum-param

Conversation

@ako

@ako ako commented Oct 21, 2026

Copy link
Copy Markdown
Owner

Symptom

Found while verifying #1534. Over --mcp, this fails:

create microflow MyFirstModule.X ($T: System.UserType) begin … end;
ped_create_document … {"/parameters/0/entity":"Reference with qualified name System.UserType of type DomainModels$Entity not found."}

A module enumeration (Rules.RuleResult) works.

It was never MCP-only

The local engines write the same wrong document. They just don't check references at write time:

  • mxcli bson dump shows DataTypes$ObjectType with Entity: "System.UserType".
  • mx check (11.14.0) reports [CE1613] "The selected entity 'System.UserType' no longer exists." at Parameter 'T'. A returns System.DeviceType gets the same error.
  • DESCRIBE hid it. It prints an enumeration type as enum X and an object type as a bare X, so the plausible-looking $T: System.UserType in describe output was the symptom.

The explicit $T: enum System.UserType form is what DESCRIBE emits for an enumeration parameter. It was refused with enumeration 'System.UserType' not found.

Cause

The visitor types every bare qualified name in a flow parameter or return position as TypeEntity. The executor only falls back from entity to enumeration after the entity lookup misses. For the System module it skips that lookup entirely (isBuiltinModuleEntity, because System entities are not stored in the project), so a System enumeration kept the entity guess.

The explicit form failed for a separate reason: findEnumeration reads ListEnumerations, which never includes System enumerations.

Fix

  • settleSystemEnumeration changes a TypeEntity to TypeEnumeration before validation when its name is in modelsdk/meta.SystemEnumerations. It runs at all six sites: microflow, nanoflow and rule, each for parameters and the return type.
  • isKnownEnumeration treats a System enumeration as known even though findEnumeration cannot see it.
  • System.User still becomes an object type. A test controls for this.

findEnumeration is deliberately left unchanged. Returning a synthetic System enumeration from it would make ALTER/DROP ENUMERATION System.X reachable, which is the "making a synthesized element readable makes it writable" trap in docs-wiki/bug-patterns/platform-semantics-gaps.md.

Verification

  • Unit (mdl/executor/system_enum_flow_type_test.go). The tests parse real MDL, so the visitor's entity guess is exercised. They cover a bare parameter, a bare return type, an explicit enum parameter, a nanoflow parameter, and a System-entity control. With settleSystemEnumeration stubbed to identity, the three bare-name tests fail with got *microflows.ObjectType. The explicit-enum test failed before the fix with the "not found" refusal.
  • Live over --mcp, Studio Pro 11.15.0-rc.4. Created MyFirstModule.MCPE_SysEnumParam and MCPE_SysEnumReturn. ped_read_document reads back:
    "/objectCollection/objects/0/variableType": {"$Type": "DataTypes$EnumerationType", "enumeration": "System.UserType"}
    "/microflowReturnType":                     {"$Type": "DataTypes$EnumerationType", "enumeration": "System.DeviceType"}
    Control: the same build with the fix stubbed reproduces the reported PED error verbatim.
  • Local (default engine) + mx check 11.14.0 on mdl-examples/bug-tests/mcp-system-enumeration-parameter.mdl against a copy of TestApp: 2× CE1613 before, 0 errors after. DESCRIBE now round-trips as $T: enum System.UserType.
  • go test ./mdl/... ./cmd/mxcli/... ./modelsdk/...: all 84 packages pass. mdl/executor and mdl/backend/modelsdk hit the 10-minute default timeout on a heavily loaded devcontainer (load average ~11), then passed in a rerun with -timeout 40m (609s and 589s). go vet, gofmt and make check-findings are clean.

Checklist

  • Fix-issue findings consulted (closest: the System-module paragraph of platform-semantics-gaps.md; nothing on enum-vs-entity for System references)
  • Finding recorded: .claude/skills/fix-issue/findings/mdl-executor/2026-10-21-system-enumeration-flow-parameter-written-object-type.json
  • Test written first and shown to fail with the reported symptom
  • Bug-test script: mdl-examples/bug-tests/mcp-system-enumeration-parameter.mdl
  • No backend / BSON changes; the executor still goes through ctx.Backend

🤖 Generated with Claude Code

…umeration

`create microflow M.X ($T: System.UserType)` was written as
DataTypes$ObjectType with Entity "System.UserType" on every engine. The
visitor types each bare qualified name in a parameter or return position
as an entity, and the executor's entity-then-enumeration fallback skips
the System module outright (its entities are not stored in the project),
so a System enumeration kept the entity guess.

The local engines wrote it without complaint and DESCRIBE printed a
plausible bare `System.UserType` (an enumeration renders as `enum X`),
but mx check reports CE1613 "The selected entity 'System.UserType' no
longer exists" for the parameter and for a System-enum return type.
Studio Pro's PED refuses it at write time, which is how it surfaced over
--mcp. The explicit `enum System.UserType` spelling, what DESCRIBE emits
for an enumeration, was refused as "enumeration not found", because the
System module's enumerations are not in ListEnumerations.

settleSystemEnumeration retypes a name in meta.SystemEnumerations before
validation at all six sites (microflow, nanoflow, rule x parameter,
return type), and isKnownEnumeration accepts a System enumeration where
findEnumeration cannot see it. System.User stays an object type.

Verified over --mcp on Studio Pro 11.15.0-rc.4: ped_read_document reads
back DataTypes$EnumerationType for the parameter and the return type; a
stubbed-fix control reproduces the PED error. Locally, mx check 11.14.0
goes from 2x CE1613 to 0 errors.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ako
ako merged commit 14b58b2 into main Oct 21, 2026
31 checks passed
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.

1 participant