feat: valid-but-deprecated grammar values behind the experimental flag (AF families + IPMasquerade booleans)#495
Merged
Merged
Conversation
…ntal flag A value can be perfectly valid yet use an obsolete token — e.g. an address family the kernel removed but af_from_name still resolves. Add a reusable deprecation layer: - TerminalCombinator.deprecationFor(token): String? = null — additive hook. - FlexibleLiteralChoiceTerminal.deprecating(map) marks choices obsolete. - Combinator.deprecatedTokens(value) reports them from the first fully-VALID parse, so a deprecation note never stacks on an InvalidValue error. - DeprecatedGrammarValueAnnotator renders them as WEAK_WARNINGs, gated behind ExperimentalSettings.useGrammarParseEngine (off by default, like the other grammar-engine features). First user: RestrictAddressFamilies= warns on AF_DECnet / AF_IRDA / AF_ECONET / AF_WANPIPE (kernel-removed, reasons per address_families(7)). Re-cut of stacked PR #484 against current 242.x. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Unit Test Results (grammar engine true)1 159 tests 1 159 ✅ 49s ⏱️ Results for commit 66c5a80. ♻️ This comment has been updated with latest results. |
Unit Test Results (grammar engine false)1 159 tests 1 159 ✅ 48s ⏱️ Results for commit 66c5a80. ♻️ This comment has been updated with latest results. |
A second user of the deprecation layer, found by scanning systemd.network(5): the boolean forms of IPMasquerade= "are now deprecated. Please use one of the values above" (ipv4/ipv6/both/no). The validator already enumerated the eleven boolean aliases as accepted values; mark them deprecated so they get the weak warning (truthy -> use "ipv4", falsy -> use "no"). Demonstrates the layer is generic across grammars, not AF-specific. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.
What
A reusable, opt-in layer that flags valid-but-deprecated values as a weak warning ("obsolete, has no effect"), not an error.
Design
TerminalCombinator.deprecationFor(token): String? = null— additive interface hook.FlexibleLiteralChoiceTerminal.deprecating(choice -> reason)— marks specific choices obsolete.Combinator.deprecatedTokens(value)— reports from the first fully-valid parse only, so a deprecation note never piles on top of anInvalidValueerror.DeprecatedGrammarValueAnnotatorrenders them asWEAK_WARNINGs, gated behindExperimentalSettings.useGrammarParseEngine(off by default, like the other grammar-engine features).Two users (the layer is generic, not AF-specific)
RestrictAddressFamilies=—AF_DECnet/AF_IRDA/AF_ECONET/AF_WANPIPE(kernel-removed; the libc macro lingers soaf_from_namestill accepts them). Authority is the Linux side, not systemd.IPMasquerade=— the legacy boolean forms (1/yes/y/true/t/on/0/n/false/f/off), whichsystemd.network(5)says "are now deprecated. Please use one of the values above" (ipv4/ipv6/both/no). Authority is systemd's own docs here.Verification
./gradlew testand./gradlew test -Dsystemd.unit.grammarParseEngine=trueboth pass. Tests cover warned / not-warned / flag-off, plus unit tests ofdeprecatedTokensfor both users.🤖 Generated with Claude Code