Skip to content

feat: valid-but-deprecated grammar values behind the experimental flag (AF families + IPMasquerade booleans)#495

Merged
SJrX merged 2 commits into
242.xfrom
grammar-value-deprecation
Jun 26, 2026
Merged

feat: valid-but-deprecated grammar values behind the experimental flag (AF families + IPMasquerade booleans)#495
SJrX merged 2 commits into
242.xfrom
grammar-value-deprecation

Conversation

@SJrX

@SJrX SJrX commented Jun 26, 2026

Copy link
Copy Markdown
Owner

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 an InvalidValue error.
  • DeprecatedGrammarValueAnnotator renders them as WEAK_WARNINGs, gated behind ExperimentalSettings.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 so af_from_name still 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), which systemd.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 test and ./gradlew test -Dsystemd.unit.grammarParseEngine=true both pass. Tests cover warned / not-warned / flag-off, plus unit tests of deprecatedTokens for both users.

🤖 Generated with Claude Code

…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>
@github-actions

github-actions Bot commented Jun 26, 2026

Copy link
Copy Markdown

Unit Test Results (grammar engine true)

1 159 tests   1 159 ✅  49s ⏱️
  304 suites      0 💤
  304 files        0 ❌

Results for commit 66c5a80.

♻️ This comment has been updated with latest results.

@github-actions

github-actions Bot commented Jun 26, 2026

Copy link
Copy Markdown

Unit Test Results (grammar engine false)

1 159 tests   1 159 ✅  48s ⏱️
  304 suites      0 💤
  304 files        0 ❌

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>
@SJrX SJrX changed the title feat: warn on valid-but-deprecated grammar values behind the experimental flag feat: valid-but-deprecated grammar values behind the experimental flag (AF families + IPMasquerade booleans) Jun 26, 2026
@SJrX SJrX merged commit 9827df9 into 242.x Jun 26, 2026
5 checks passed
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.

1 participant