Skip to content

Re-runnable domain scripts: exec --continue-on-error + idempotent ADD/DROP ATTRIBUTE - #32

Merged
ako merged 2 commits into
mainfrom
fix/rerunnable-domain-scripts
Jul 26, 2026
Merged

Re-runnable domain scripts: exec --continue-on-error + idempotent ADD/DROP ATTRIBUTE#32
ako merged 2 commits into
mainfrom
fix/rerunnable-domain-scripts

Conversation

@ako

@ako ako commented Jul 25, 2026

Copy link
Copy Markdown
Owner

Sudoku-app finding #10: domain-delta scripts couldn't be replayed. alter entity … add attribute X errored attribute 'X' already exists on a second run, and because exec halts on the first error, a script that was 90% already-applied applied none of the remaining 10%. This app needed 25 single-statement alters where 3 would have done, and couldn't re-run 01/02 at 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 — and exit/quit still stop the run. Works for every statement type, so any partially-applied script becomes re-runnable.

IF NOT EXISTS / IF EXISTS on attributes (surgical)

ALTER ENTITY … ADD ATTRIBUTE IF NOT EXISTS X: T and … DROP ATTRIBUTE IF EXISTS X turn 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.)

alter entity Sudoku.Game add attribute if not exists PuzzleNo: integer default 1;
alter entity Sudoku.Game drop attribute if exists LegacyFlag;

Tests & docs

  • ExecuteProgramContinueOnError unit tests (mixed success/fail counting; exit still halts).
  • Visitor test (guards set the AST flags; plain forms don't) + executor mock tests (add-existing → skip, add-new → applied, drop-absent → skip, plain forms still error).
  • Bug-test example, mxcli syntax entry, MDL_QUICK_REFERENCE.md rows, and a fix-issue.md symptom row.

Generated ANTLR parser files under mdl/grammar/parser/ are not committed (regenerated by make).

🤖 Generated with Claude Code


Generated by Claude Code

claude added 2 commits July 25, 2026 21:39
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
ako merged commit 6bc927c into main Jul 26, 2026
3 checks passed
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
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.

2 participants