mdl: deprecation registry for MDL aliases (MDL-DEPRnnn) - #727
Merged
Merged
Conversation
One registry of deprecated MDL spellings (ADR-0011 decision 1), generalising the MDL065 pattern: both spellings build the same AST, so the visitor records which one the source used on ast.Program.Deprecations, and check/exec warn through ValidateProgram. --deprecations=error fails the run instead. Grammar aliases are marked with /* @alias MDL-DEPRnnn */ next to the token; TestGrammarAliasesAreRegistered fails on a marker with no registry entry, or an entry no marker names. Seeded with create or replace -> create or modify (MDL-DEPR001) and show -> list (MDL-DEPR002). create or replace is only reported where it builds the same statements as create or modify; view entity, translations, user role and demo user differ today and are exempt, pinned per create kind. Closes #709 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ist` The proposal's decided mapping for `show` (PROPOSAL_mdl_beta_syntax_freeze.md §3, R6) sends single things to `describe` (show entity X, show navigation, show project security, show structure, show context of X, …) and session state (show version, show status, show connections, show catalog status) to REPL commands. Warning "write `list …`" on those named a non-canonical form, and `fmt --upgrade` consuming the rewrite would have rewritten them twice. They are left unreported until their canonical forms exist (plan item 3.5). Also adds tests for the mdl/deprecation package itself: registry entries are well-formed and unique, and ParsePolicy refuses unknown values. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…on-registry # Conflicts: # mdl/ast/ast.go # mdl/executor/validate_program.go # mdl/visitor/visitor.go
11 tasks
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.
Closes #709. Plan item 1.2 of
PROPOSAL_mdl_beta_syntax_freeze.md, and ADR-0011 decision 1. Tracking: #714.What
There is now one registry of deprecated MDL spellings, and
checkandexecwarn on each use of one. The only behaviour change is new warnings: nothing is removed, and every script runs as before.mdl/deprecationis the registry. Each entry holds a code (MDL-DEPRnnn), the old form, the canonical form, a mechanicalRewrite(a token swap, forfmt --upgradein 1.3),RemovedIn(a language version), a note, and two examples: one in the old form and its canonical rewrite.ast.Program.Deprecations(code, line, column, subject). It does this from the parse tree:ExitCreateStatementand a newExitShowOrList.executor.ValidateDeprecationsruns insideValidateProgram, socheckandexecboth get it. Each warning names the line, the canonical form, and the version that will refuse the old form.--deprecations=warn|erroris a new flag oncheckandexec. Witherror, onlyMDL-DEPR*findings are promoted to errors. An unknown value exits with code 2 rather than being treated aswarn, so a typo cannot quietly pass a CI gate./* @alias MDL-DEPRnnn */goes next to the alias token, and ANTLR ignores it.TestGrammarAliasesAreRegistered(inmdl/grammar) reads the.g4sources. It fails on three things: a marker whose code has no registry entry, a malformed marker, and a registry entry that no marker names.TestAliasMarkerCheckerDetectsProblemsis the control: it feeds the checker a grammar that is bad in each of those three ways.MDL-DEPR001create or replacebecomescreate or modify, marked atMDLParser.g4createStatement.MDL-DEPR002showbecomeslist, marked atMDLCatalog.g4showOrList.MDL-DEPRnnnsection todocs-site/src/appendixes/error-messages.md. It points to the registry and does not copy it.Design choices the ADRs did not settle
create or replaceis reported only where it is an exact alias. I measured each create kind against the visitors. For four kinds,or replacedoes not meanor modifytoday:view entitydrops and recreates.translationsreplaces the whole set instead of merging.user roleanddemo userignorereplace, so the statement is a plain create.Telling users to rewrite those would change their scripts, so those four are exempt.
TestCreateOrReplaceMatchesModifyExceptExemptKindspins this in both directions for every kind increateStatement, which it reads from the grammar, so a new kind fails until it has a case:DeepEqualstatements foror replaceandor modify.Page, snippet and layout keep separate
IsReplace/IsModifyflags. Every reader of those flags testsIsModify || IsReplace, so the test folds the two together.show→list, reported only wherelistis the canonical form (narrowed in review, commit ce68cc6). The proposal's decided mapping (§3, R6) sends plurals and relationship queries tolist, single things todescribe(show entity|association|page X,show navigation …,show structure,show context of X,show project security,show security matrix,show settings) and session state (show version|status|connections,show catalog status) to REPL commands.listbuilds the same statement for all of them today, but recommendinglist entity Xorlist versionwould name a non-canonical form and makefmt --upgraderewrite those scripts twice. So those forms are not reported yet; they get their own entries once their canonical forms exist (3.5).showNotYetListinvisitor_deprecations.goholds the exclusions, keyed on the token aftershow;TestShowRecordsDeprecationpins both sides.Out of scope for
show:show lint ruleshas nolistform, andsql <conn> show …is a different statement. Neither is an alias, so neither is marked. The microflow activitiesshow pageandshow messageare covered by a negative test.RemovedIn: 2. ADR-0011 and proposal §6 say an alias warns under the version that deprecates it and is refused under the next one.mdl 1is beta, so these are refused frommdl 2.MDL065 keeps its code. Moving the split
case/elsespellings into the registry would rename a warning that existing tests and users key on. I left that as a follow-up.Test plan
go test ./mdl/visitor ./mdl/executor ./mdl/grammar -run 'Deprecat|CreateOrReplace|RegistryExamples|ShowRecords|Alias': pass.recordCreateOrReplacecall failsTestRegistryExamplesRecordTheirCodeandTestCreateOrReplace…("recorded [], want [MDL-DEPR001]").ExitShowOrListfails the show, position and executor tests.userroleexemption fails with "or replaceandor modifybuild different statements".MDL-DEPR002registry entry failsTestGrammarAliasesAreRegisteredwith "domains/MDLCatalog.g4:12: grammar alias MDL-DEPR002 has no entry in mdl/deprecation".ApplyDeprecationPolicya no-op failsTestDeprecationPolicyErrorFailsTheRun.bin/mxcli check:create or replace enumeration,show entitiesandcreate or replace translationsgets 2 warnings and exits 0. The translations statement is correctly not reported.--deprecations=errorgets 2 errors and exits 1.--deprecations=bogusexits 2.--deprecations=errorpasses.make build: pass.make lint: pass (Go and TS).make test: the first run failed with "no space left on device". The shared/tmptmpfs was full because other agents are using it, and those failures were in fixture copies and compile output. I re-ran withTMPDIRon the large disk. Everything passed exceptmdl/backend/modelsdk, which hit the 10-minute default timeout on a loaded machine. Re-run alone with-timeout 40m, it passes (463s). This change does not touch that package.Review (independent reviewer)
mdl/deprecation/deprecation_test.go(the new package had no tests): registry entries well-formed/unique/complete,RemovedIn >= 2, andParsePolicyrefuses unknown values (stubbing the error path fails 4 cases).make build,make lintpass. Fullgo test ./...withTMPDIRon the large disk: only environment failures (unix-socket chmod on the overlay FS intui, and two packages that failed to build mid-run while I rebuiltbin/);tui,docker,tunnelhubandcmd/mxcliall pass re-run on their own.bin/mxcli checkovershow entity M.E; show version; show entities;with--deprecations=error: 1 error (line 3 only), exit 1.Follow-ups (not in this PR)
describe navigationstill emitscreate or replace navigation(cmd_navigation.go). ADR-0011 says describe never emits a deprecated form, so it should switch tocreate or modify. That is a describe-output change, so it gets its own PR.create or replace(cmd_entities.go"already exists" hint,cmd_misc.gohelp, the translations messages). The skills and docs also useshow/create or replacewidely. The 1.4 conformance gate will surface those.showforms (single things →describe, session state → REPL) once those canonical forms exist (3.5).create or replacekinds. They are changes of meaning, not aliases, so they belong to the version header (1.5).case/elsespellings) into the registry.fmt --upgrade(1.3) consumesEntry.Rewrite.🤖 Generated with Claude Code