TRF041

A config-gated branch must carry a # CODEPATH: note saying which checkpoints diverge.

   
Default Enabled
Scope Models added on or after 2026-06-20
Source mlinter/trf041.py
Show in terminal mlinter --rule TRF041

What it does

In modeling_*.py and modular_*.py, flags every if/elif and conditional expression whose condition reads a config.* or self.config.* attribute without a # CODEPATH: comment, accepted on the branch line or in the contiguous comment block directly above it. Any config attribute counts, not just boolean flags. Exempt by structure: X if X is not None else fallback, where the tested field is itself one of the results – getattr(config, x, default) spelled long, which cannot fork the graph; and a guard, an if with no else whose body only raises or only warns/logs, since one side aborts and nothing diverges past it. Merely mentioning None does not qualify: config.vision_config is not None still owes a note. Exempt by field: framework plumbing that gates no checkpoint divergence – problem_type selecting a loss, hidden_act looking up an activation, num_labels, use_cache, is_decoder, the special token ids, the summary_* head settings; the full list is DEFAULT_EXEMPT_ATTRIBUTES in mlinter/trf041.py, extended per project by ignored_attributes = [...] on the rule table. A model exempts one of its own fields file-wide with a module-level # trf-ignore: TRF041 config.scale_embedding, config.auxiliary_loss at column 0 (self.config.x, config.x and x are the same field). It must name at least one field – a bare # trf-ignore: TRF041 keeps its per-line meaning – and a condition is skipped only when every field it reads is exempt.

Why is this bad?

A config-gated branch is a second architecture in the same file, and the code cannot say whether both halves are still reachable – which is how dead experimental branches survive for releases. The rule does not forbid the branch: like Rust’s // SAFETY:, it asks for the checkpoints taking each side to be written down next to it. A branch nobody can name one for is a branch to delete.

Example

+        # CODEPATH: ESMC-6B ships pre-normalised embeddings, the 300M/600M checkpoints do not.
         if config.use_embedding_norm:
             hidden_states = self.embedding_norm(hidden_states)

-        if config.msa_encoder_enabled:
-            hidden_states = self.msa_encoder(hidden_states)
+        # no released checkpoint sets msa_encoder_enabled -> branch removed

Suppressing this rule

Add a # trf-ignore: TRF041 comment on the flagged line or the line directly above it. See Suppressing rules for whole-file directives and when a suppression is the wrong answer.

Allowlisted models

7 models are exempt from TRF041 in mlinter/rules.toml, because they predate the convention and cannot be changed without breaking backward compatibility.

Show the 7 allowlisted models
  • dinov3_vit
  • inkling
  • kimi_k25
  • kosmos2
  • mimo_v2_flash
  • tipsv2
  • x_clip