Regula rule reference

This page documents Regula 4.34.0. The latest release is Regula 0.11.1: this page in Regula 0.11.1.

RG2006: Claimed targets must build with the community configuration🔗

  • Category Configuration
  • Scope project
  • Subreason community-configuration

A claimed library or executable is built with automatic implicits on or without Lean's linter.missingDocs, turns off a linter for all its modules beyond the three Mathlib-repository linters that standard §6.7 excludes, overrides these options with a -D extra lean argument, or, in a surface that imports Mathlib, leaves Mathlib's standard linter set or its exclusions unset.

What to do. Set the target's Lake leanOptions: autoImplicit and relaxedAutoImplicit false, linter.missingDocs true and, with Mathlib, the standard set and its three §6.7 exclusions; remove other linter disables and each -D extra lean argument that overrides these options.

Requirement
Each claimed target sets in leanOptions: automatic implicits off, linter.missingDocs on, no linter off beyond the §6.7 exclusions and, with Mathlib, its standard set on; no -D undoes this.
Reported in
Project
Enforcement
Strict, like every rule: see how rules are enforced.

Checked example🔗

Violating input

lakefile.lean (written by the qualification runner) differs; its change is shown under Correction.

Unchanged input

Example.leansource examples/rules/RG2006/Example.lean
/-! # Identity

The identity function, with its type parameter declared. -/

/-- The identity function on any type `α`. -/
def identity {α : Type} (a : α) : α := a

Findings of the violating run

RG2006 error violation fresh project, claim kernel-only

Subject Example at project <example>

community-configuration: `autoImplicit` is not set; set it to false; `relaxedAutoImplicit` is not set; set it to false; `linter.missingDocs` is not set; set it to true

Correction

Change to lakefile.lean
  import Lake
  open Lake DSL
  
- package rule_examples
+ package rule_examples where
+   leanOptions := #[⟨`linter.missingDocs, true⟩, ⟨`autoImplicit, false⟩,
+     ⟨`relaxedAutoImplicit, false⟩]
  
  @[default_target]
  lean_lib Example
  ⋯ 2 unchanged lines

The examples are the package's lakefile.lean (the corpus run adds its require regula line). The correction adds the three options every claimed target sets, automatic implicits off and linter.missingDocs on, without changing the library or its source.

Checked by a fresh whole-project audit of <example> (axiomGate): violating run rejected, corrected run completed.

How to fix it🔗

  1. Add ⟨`autoImplicit, false⟩, ⟨`relaxedAutoImplicit, false⟩, ⟨`linter.missingDocs, true⟩ to leanOptions (the same keys under [leanOptions] in lakefile.toml), then declare each universe and implicit the build reports as unknown and document each declaration it reports.

  2. With Mathlib, also set weak.linter.mathlibStandardSet to true and weak.linter.style.header, weak.linter.hashCommand false and weak.linter.style.longFile 0.

  3. Replace a target-wide ⟨`linter.X, false⟩ with set_option linter.X false in on the one declaration the community's guidance allows, with a comment (§6.2).

  4. Delete each -D name=value in moreLeanArgs or weakLeanArgs that gives one of these options another value or turns off another linter; other extra arguments may stay.

Why it matters🔗

An automatic implicit adds a binder the source does not show, so the elaborated statement can quantify over more than the text a reviewer compares with the intent. A linter reports only where it is on: without linter.missingDocs, or with a linter off for a whole target, the warning-free build (RG2003) never sees those warnings. A -D extra lean argument can override leanOptions, where the audit reads these options.

Standard §7.1 requires the options because they decide which binders a declaration's elaborated type has. Standard §6.7 adopts the community's linters as its conventions baseline, and a linter enforces its convention only where it is on: RG2003 rejects warnings, not a missing linter.

What triggers it🔗

After the claimed surfaces build, the checker reads Lake's resolved configuration of every claimed library and executable: its leanOptions (build type, package, then target, a later entry replacing an earlier one) and its weakLeanArgs and moreLeanArgs. The proved decision RegulaPolicy.Community.failures rejects the target, with applicability community-configuration, when autoImplicit or relaxedAutoImplicit is not set to false or linter.missingDocs is not set to true, when any other linter.… option than linter.style.header, linter.hashCommand and linter.style.longFile is set to false, or when a -D name=value among the extra arguments gives a required option another value or sets such a linter to false.

A target of a surface whose loaded environment contains a Mathlib module must also set weak.linter.mathlibStandardSet to true, weak.linter.style.header and weak.linter.hashCommand to false, and weak.linter.style.longFile to 0.

A key's leading weak. component is read as the option it sets; a target that gives one option under both spellings must give the required value under each. A string value counts as Lean parses it for the option: "false" is false and "0" is 0. One finding per target lists every failure.

Every -D that lean reads starts at the first D of an argument that begins with a single - (-D, or after flags as in -qD), with its value after the D or in the next argument; the rule reads every such candidate, so it can also reject one that lean does not read as a -D, such as the value of -o. Any other extra argument is allowed.

What a passing result establishes🔗

Every claimed library and executable is built through Lake with automatic implicits off and linter.missingDocs on, turns off no linter target-wide beyond the §6.7 exclusions and, in a Mathlib surface, enables the standard set with exactly those exclusions; no -D extra lean argument overrides these options.

It does not establish:

  • That no module sets an option back in source, such as set_option autoImplicit true or a linter disable; review checks source options (§6.2).

  • That the community linters' own checks pass, such as a docstring on every public declaration; their warnings are RG2003's.

  • That extra lean arguments other than -D, such as --plugin or --setup, leave the options unchanged.

It leaves these review obligations open: R-QUALIFY, R-INTENT.

Configuration and exceptions🔗

The Lake configuration is the input; no manifest field, source option or command-line flag exempts a claimed target.

Limitations and unsupported cases🔗

Options given on lake's own command line are not read; the rule reads what Lake resolves for the workspace the audit loads.

Whether a surface imports Mathlib is read from its whole loaded environment, so every claimed target of such a surface, including an executable whose own root does not import Mathlib, needs the Mathlib options.

The -D reading is assumed to cover the command-line parser of the Lean executable, as read from Lean's Lean.Shell source and its getopt handling; that correspondence is neither proved nor observed.

The rule runs in project audits only; editor feedback does not read Lake configuration.

Sources🔗

Normative clauses
standard §7.1 Declare the Elaboration Environment, standard §6.7 Community Conventions and Linters, standard §6.2 Module Purpose and Linter Discipline
Checklist rows
DECL-01, DOC-01
Detector, policy and proof sources
lean/RegulaPolicy/Community.lean, lean/Regula/Checker/Lake.lean, lean/Regula/Checker/AxiomGate.lean, website/RegulaStandard/CodeOrganization.lean
Proved linkage
RegulaPolicy.Community.failures_eq_nil_iff, conforming_of_mathlib, conforming_missingDocs, leanArgument_mem_failures_iff and missingDocs_unset_fails. Reading Lake's target configuration is operational.