Re-runnable domain scripts: exec --continue-on-error + idempotent ADD/DROP ATTRIBUTE - #32
Merged
Conversation
Findings #10: `exec` halted on the first error, so re-running a domain script that is 90% already-applied (e.g. "attribute already exists") applied none of the remaining 10%. Add ExecuteProgramContinueOnError: it attempts every statement, reports each failure prefixed with its statement number, and returns a summary; the CLI exits non-zero when any statement failed. Unlike a blanket error-swallow, every failure is still surfaced, so a real mistake stays visible. `exit`/`quit` (ErrExit) still stop the run. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JXnEgoc2NQP1Y2TWMCMXC4
Findings #10: with no way to re-apply a domain delta, re-running a script that adds an attribute erroring "already exists" was a hard error. Add IF NOT EXISTS to ADD ATTRIBUTE and IF EXISTS to DROP ATTRIBUTE (grammar + AST + visitor + executor): when the attribute is already present / already gone, the op is skipped with a notice instead of erroring, so a domain script re-runs cleanly and converges. The plain forms still error, so the guard is explicit and opt-in. Includes visitor + executor tests, a bug-test example, and syntax/quick- reference/symptom-table docs. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JXnEgoc2NQP1Y2TWMCMXC4
ako
pushed a commit
that referenced
this pull request
Jul 29, 2026
- #37: write-oql-queries.md RULE 2 said "NEVER use ORDER BY or LIMIT in a view", but mxcli's MDL030 *requires* ORDER BY to be paired with a LIMIT (ORDER BY alone → CE0174; ORDER BY + LIMIT builds clean). Reworded RULE 2 + the Mistake 8, Step 9, and checklist entries to match the tool, and documented UNION/UNION ALL as a supported construct (it worked end-to-end but was undocumented). - #32: MDL001 (nested-loop) reworded — it now distinguishes a key LOOKUP (use FIND) from intentional aggregation that must visit every element (correct as written), so it stops reading as "your loop is wrong" on report pivots. - #31: documented that a variable first created inside an if/else arm (including by `$Var = call ...`) is scoped to that arm — declare before, assign in each. - #34: run-local.md notes the Dart Sass `rgba()` comma-list trap (a theme compile error fails the build step pre-runtime). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JXnEgoc2NQP1Y2TWMCMXC4
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Sudoku-app finding #10: domain-delta scripts couldn't be replayed.
alter entity … add attribute Xerroredattribute 'X' already existson a second run, and becauseexechalts on the first error, a script that was 90% already-applied applied none of the remaining 10%. This app needed 25 single-statementalters where 3 would have done, and couldn't re-run01/02at all.Two complementary mechanisms, one per commit:
mxcli exec --continue-on-error(general)Attempts every statement instead of halting at the first failure; each failure is reported as
statement N: …and the command exits non-zero if any failed. A real error is still surfaced — never masked — andexit/quitstill stop the run. Works for every statement type, so any partially-applied script becomes re-runnable.IF NOT EXISTS/IF EXISTSon attributes (surgical)ALTER ENTITY … ADD ATTRIBUTE IF NOT EXISTS X: Tand… DROP ATTRIBUTE IF EXISTS Xturn the already-applied case into a skip-with-notice instead of an error, so a domain script re-runs cleanly and converges. The plain forms still error, so the guard is explicit and opt-in. (Grammar → AST → visitor → executor, full pipeline.)Tests & docs
ExecuteProgramContinueOnErrorunit tests (mixed success/fail counting;exitstill halts).mxcli syntaxentry,MDL_QUICK_REFERENCE.mdrows, and afix-issue.mdsymptom row.Generated ANTLR parser files under
mdl/grammar/parser/are not committed (regenerated bymake).🤖 Generated with Claude Code
Generated by Claude Code