Skip to content

Commit faa9790

Browse files
akoclaude
andcommitted
docs: add mx dump-mpr as Path 5 in schema extraction proposal
Adds `mx dump-mpr --module-names='System'` as a fifth extraction path for System module metadata (entities, enumerations, Java actions, microflows). Unlike the MCP/PED paths this requires no running Studio Pro — only the mx binary and a blank .mpr — making it CI-friendly and available on all supported Mendix versions. Also adds Phase 1.5 to the implementation plan (mxcli schema extract-system) which can ship independently before any MCP plumbing is in place, and updates the coverage table and Open Question #1 accordingly. Updates the review.md recurring findings table with Finding #12 (mock tests constructing Kind values the real parser cannot produce). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent d139b1f commit faa9790

2 files changed

Lines changed: 66 additions & 3 deletions

File tree

.claude/commands/mxcli-dev/review.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ proactively. Add a row after every review that surfaces something new.
3434
| 9 | Doc comment promises a fallback/feature that doesn't exist in the code (e.g., "raw-map fallback in the client" when no such fallback was implemented) | Docs quality | Grep for function/type names referenced in doc comments to confirm they exist before committing |
3535
| 10 | BSON array items decoded by mongo driver are `primitive.D`, not `map[string]any` — bare type assertion `item.(map[string]any)` always fails silently, causing silent data loss (e.g. Languages not parsed, issue #480) | BSON parsing | Always use `extractBsonMap(item)` instead of `item.(map[string]any)`; write a parser unit test with `primitive.D` items to catch this class of bug |
3636
| 11 | `execShow` switch missing a case for a new `ShowXxx` constant — executor handler is wired but never dispatched, command silently does nothing | Dispatch gap | After adding a new `Show*` constant and handler, grep `executor_query.go` to confirm the case is present; add a mock test that calls the handler directly |
37+
| 12 | Mock test constructs a `Kind` value (e.g. `"Array"`) that `parseImportMappingElement` can never produce — parser only sets `"Object"` or `"Value"` — giving false assurance for a code path that is dead against real MPR data | Test coverage | Before writing a mock test for a fallback path, verify the parser can actually produce the mocked value; if not, either extend the parser or remove the dead fallback |
3738

3839
---
3940

docs/11-proposals/PROPOSAL_schema_extract.md

Lines changed: 65 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,57 @@ types, traversing the schema graph from each document root.
133133
**Schema extraction**: Create a minimal instance of each type (entity, enumeration,
134134
association, etc.), decode the mxunit, and classify fields using the same algorithm.
135135

136+
### Path 5: System module — `mx dump-mpr`
137+
138+
**Problem**: The System module is a built-in, protected module. PED does not expose it for
139+
traversal, and it does not appear in `ListJavaActions()` because its documents are not stored
140+
in the user's `.mpr` file in the same way as user-defined documents. However, several mxcli
141+
features depend on knowing System's entities, enumerations, and Java actions:
142+
- `mxcli check --references` validates Java/JavaScript action calls against the catalog
143+
- `SHOW ENTITIES` hides or shows System entities based on `system_module.go`
144+
- Type inference for generalizations (e.g. `System.User`) requires knowing System entity attributes
145+
146+
**Command**: `mx dump-mpr` exports the full model as JSON, and includes the System module by
147+
default (it even has an `--exclude-system-module` flag to opt out).
148+
149+
```bash
150+
# Full System module JSON
151+
mx dump-mpr --module-names='System' blank.mpr
152+
153+
# Just the domain model (entities, attributes, generalizations, associations)
154+
mx dump-mpr --module-names='System' --unit-type='DomainModels$DomainModel' blank.mpr
155+
156+
# Just Java actions (e.g. System.VerifyPassword)
157+
mx dump-mpr --module-names='System' --unit-type='JavaActions$JavaAction' blank.mpr
158+
159+
# Just enumerations (WorkflowState, UserType, DeviceType, etc.)
160+
mx dump-mpr --module-names='System' --unit-type='Enumerations$Enumeration' blank.mpr
161+
```
162+
163+
Running against Mendix 11.9.0 produces (sample):
164+
- **1 Java action**: `System.VerifyPassword(userName, password) → Boolean`
165+
- **1 Microflow**: `System.ShowHomePage`
166+
- **14 Enumerations**: `WorkflowState`, `WorkflowActivityExecutionState`, `DeviceType`,
167+
`UserType`, `QueueTaskStatus`, `ContextType`, `EventStatus`, etc.
168+
- **Domain model**: all System entities (User, Session, FileDocument, Token, etc.) with
169+
attributes, generalizations, and associations — same content as `system_module.go`
170+
171+
**Use as a generation source**: Run `mx dump-mpr --module-names='System'` against a blank
172+
project for each target Mendix version. Parse the resulting JSON to regenerate:
173+
- `sdk/mpr/system_module.go` — the `systemEntities` list (currently hand-maintained from 11.6.4)
174+
- `BuildSystemJavaActions()` — currently absent; needed for catalog Java action validation
175+
176+
The `.mpr` file can be a blank project created via `mxcli new`. Exit code `4` ("project is in
177+
different Mendix version") acts as a version guard — the right `mx` binary must be used.
178+
179+
**Advantages over other paths**:
180+
- Does not require Studio Pro to be running (only the `mx` CLI binary)
181+
- Works on all supported Mendix versions (not just those with MCP/PED support)
182+
- Output is authoritative structured JSON from `mx` itself — not derived from TypeScript
183+
artifacts or regex-parsed compiled JS
184+
- CI-friendly: `mxcli setup mxbuild` already downloads the `mx` binary per version
185+
- `--unit-type` filtering makes it precise and fast
186+
136187
## Output Format
137188

138189
The extractor writes one JSON file per Mendix version:
@@ -243,6 +294,7 @@ designed to be compatible with either source.
243294
| Built-in widgets | 78 | Known list + pagegen + mxunit | Full |
244295
| Pluggable widgets | project-dependent | `.mpk` XML parse | Full (per project) |
245296
| Other document types | ~40 domains | PED schema traversal + mxunit | Partial (reachable types only) |
297+
| **System module** | entities, enums, Java actions, microflows | `mx dump-mpr --module-names=System` | **Full — no MCP needed** |
246298

247299
## Implementation Plan
248300

@@ -252,6 +304,14 @@ designed to be compatible with either source.
252304
- Decode mxunit, classify fields, write `{version}-extracted.json`
253305
- Validate: compare extracted storage names against current CLAUDE.md table
254306

307+
### Phase 1.5: System module generator (no MCP required)
308+
- Implement `mxcli schema extract-system --version X.Y.Z`
309+
- Download `mx` for the target version via existing `mxcli setup mxbuild` logic
310+
- Create a blank `.mpr` with `mxcli new`, run `mx dump-mpr --module-names='System'`, parse JSON
311+
- Generate updated `sdk/mpr/system_module.go` (entity list) and `BuildSystemJavaActions()`
312+
- Write System section into `{version}-extracted.json` as `"systemModule": { ... }`
313+
- This phase can ship independently of the MCP extractor phases
314+
255315
### Phase 2: Domain model and nanoflow subset
256316
- Extend to domain model types (entity, attribute, association, enumeration)
257317
- Extend to nanoflow: run same list, record disallowed set
@@ -273,9 +333,11 @@ designed to be compatible with either source.
273333

274334
## Open Questions
275335

276-
1. **MCP availability**: The extractor requires a running Studio Pro instance. Should there be
277-
a fallback that uses the existing reflection data when no MCP connection is available, or
278-
should extraction always be an explicit developer operation?
336+
1. **MCP availability**: The extractor (Paths 1–4) requires a running Studio Pro instance.
337+
Path 5 (`mx dump-mpr`) is the natural fallback for the System module when no MCP connection
338+
is available — it only needs the `mx` binary and a blank `.mpr`. For non-System domains,
339+
extraction without MCP falls back to the existing reflection data. Extraction is always an
340+
explicit developer operation, not an automatic step.
279341

280342
2. **Scratch module cleanup**: The extractor creates a `_SchemaExtract` module and deletes it
281343
after. What happens if extraction is interrupted mid-run? Should it be idempotent (detect

0 commit comments

Comments
 (0)