feat: diag --check-units + grammar fixes#67
Conversation
AI Code ReviewCritical Issues
Moderate Issues
Minor Issues
What Looks Good
RecommendationRequest changes until either:
Given the truncation of the diff, verify that AST/visitor/executor changes for the grammar modifications exist in the complete diff before proceeding. If they do exist but weren't shown, this concern can be withdrawn. Automated review via OpenRouter (Nemotron Super 120B) — workflow source |
ako
left a comment
There was a problem hiding this comment.
Review
Scope concerns
This PR bundles four independent changes that should be separate PRs per the repo's checklist:
mxcli diag --check-units(new feature)- Grammar compatibility fixes (new tokens, parser rule changes)
bson dump --format bson(enhancement)- All of PR #66's changes (int32→int64, CREATE OR REPLACE PAGE UUID reuse)
The PR description just says "Stacked on #66" — the grammar changes and BSON dump format aren't mentioned at all.
Issues
1. Undisclosed ANTLR visitor generation (+2,635 lines)
Two new generated files are added (mdlparser_base_visitor.go, mdlparser_visitor.go) that don't exist on main. This means the ANTLR code generation config was changed to produce visitors in addition to listeners. This is a significant change:
- It's not mentioned in the PR description
- It's unclear if it was intentional or accidental (e.g., a different ANTLR version or flag)
- The codebase uses the listener pattern (
mdl/visitor/package) — if nobody consumes the visitor interface, these are ~2,600 lines of dead generated code
2. Grammar rules added without visitor/executor wiring
Several new grammar constructs are added but appear to have no corresponding visitor or executor code:
| Grammar addition | Visitor handler? | Executor handler? |
|---|---|---|
PLUGGABLEWIDGET token + widgetV3 rule |
Not in this PR | Not in this PR |
TABCONTAINER / TABPAGE tokens + widgetTypeV3 |
Not in this PR | Not in this PR |
keyword COLON propertyValueV3 (widget property) |
Not in this PR | Not in this PR |
Parenthesized CREATE ASSOCIATION syntax |
Not in this PR | Not in this PR |
DATASOURCE EQUALS dataSourceExprV3 (alterPageAssignment) |
Not in this PR | Not in this PR |
Per the repo's full-stack consistency checklist, new grammar rules must be wired through visitor → executor. Without that, these rules parse but silently do nothing — or worse, hit a nil/unhandled case at runtime.
3. String(unlimited) uses overly broad IDENTIFIER
: STRING_TYPE (LPAREN (NUMBER_LITERAL | IDENTIFIER) RPAREN)?This accepts String(anything) — not just String(unlimited). A dedicated UNLIMITED token or a semantic check would be safer.
4. keyword COLON propertyValueV3 is very broad
Adding keyword as a widget property name alternative means every keyword in the language can appear as a property name. This risks grammar ambiguities — e.g., FROM : someValue inside a widget block could conflict with association syntax. Was this tested for parser conflicts?
5. ListAllUnitIDs silently swallows scan errors
if err := rows.Scan(&unitID); err != nil {
continue // silently skips corrupted rows
}At minimum this should log or count the errors so users know their Unit table has issues.
6. --fix deletes files without confirmation
os.Remove(fpath) is a destructive operation. The --fix flag auto-deletes stale mxunit files without asking for confirmation. Consider either:
- Printing what would be deleted first (dry-run by default), or
- Requiring an explicit
--yes/-yflag for unattended use
The current --fix UX silently deletes and only prints after the fact.
7. All PR #66 issues still apply
Since this is stacked on #66, the same issues apply: debug logging in writer_widgets_custom.go, inconsistent array markers, comment/code mismatches. See PR #66 review.
Minor
safeInt64is still a no-op (inherited from #66)- The
.mxunitgolden files are still not wired to any test functions os.Remove(dir2)/os.Remove(dir1)for cleaning empty parent dirs silently ignore errors — acceptable for non-empty dirs, but a comment explaining the intent would help
diag --check-units: - New diagnostic command for MPR v2 projects - Detects orphan units (DB entry without mxunit file) and stale files - --fix flag removes stale mxunit files and empty parent directories - Added ListAllUnitIDs() to Reader for querying Unit table bson dump --format bson: - New raw BSON output format for roundtrip testing baseline extraction Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
13b2938 to
37ce2db
Compare
Addressed Review FeedbackRebased on latest main (PR #66 merged via #71), cleaned up scope: Changes made
Current scopePR now contains only 2 features (3 files, +119/-1):
On
|
AI Code ReviewCritical IssuesNone found. Moderate IssuesNone found. Minor Issues
What Looks Good
RecommendationApprove the PR. The changes are focused, well-implemented, and address a genuine need for MPR v2 project maintenance. The minor discrepancy between the title and diff regarding grammar fixes does not block approval since the diff shows no grammar-related changes and the core functionality is sound. Automated review via OpenRouter (Nemotron Super 120B) — workflow source |
ako
left a comment
There was a problem hiding this comment.
Review (updated — PR has been rebased and cleaned up)
This is much improved from the earlier version. Down from 18K additions/36 files to 119 additions/3 files. The grammar changes, generated parser files, and PR #66 content have been properly split out. Two focused features remain:
1. mxcli diag --check-units — looks good
Clean implementation. Two issues from my earlier review have been fixed:
- ✅
ListAllUnitIDsnow returns errors instead of silently swallowing them (return nil, fmt.Errorf(...)) - ✅
rows.Err()is checked after iteration
Remaining minor items:
-
--fixstill deletes without confirmation — this is a destructive operation. The current flow (print what's stale, then delete if--fix) is reasonable since you see the output, but a--dry-rundefault or--yesflag would be safer for scripted use. Non-blocking. -
os.Remove(dir2)/os.Remove(dir1)silently clean parent dirs — this is fine sinceos.Removefails on non-empty dirs, but a brief comment would help (e.g., "// Remove parent dirs if empty — os.Remove fails safely on non-empty dirs").
2. bson dump --format bson — clean, minimal
6 lines of logic, does exactly what it says. Good example in the help text.
Title mismatch
PR title says "grammar fixes" but those are no longer in this PR. Consider updating to match the actual content: "feat: diag --check-units + bson dump --format bson" (which matches the commit message).
Looks good to merge.
Stacked on #66