Skip to content

Conversation

@joneugster
Copy link
Collaborator

@joneugster joneugster commented Jan 16, 2026

Refactor autolabelling script to include two features:

  • option to increase maximal number of labels applied (remains at 1)
  • option to define label dependencies (meaning if multiple labels are applicable, the bot tries to reduce the number of labels following these dependencies)

This PR does NOT change the behaviour of the autolabel bot, it merely implements the functionality to do so later.

The proposed dependencies will be added as follow-ups, tracked by #34078.

Testing

Modify some files somewhere in Mathlib, make a temporary commit with these changes and run lake exe autolabel This should print all labels which would be added to the PR.

Note, that autolabel compares the current HEAD to origin/master (not master or upstream/master!) so make sure the origin/master of your fork is up-to-date.


This PR is split into 2 commits, which can be reviewed separately.

  1. Refactor existing code: make topic labels type-safe; Allow for multiple labels to be added.
  2. Add support for specifying dependent topic labels, i.e. specifying that "if t-algebraic-geometry is added, t-ring-theory should never be added". But do not provide any values for this feature

Zulip discussion: #mathlib reviewers > Proposal: automatic reviewer assignment @ 💬

Open in Gitpod

@github-actions
Copy link

github-actions bot commented Jan 16, 2026

PR summary ca7d6f198f

Import changes for modified files

No significant changes to the import graph

Import changes for all files
Files Import difference

Declarations diff

+ Label.toString
+ LabelData
+ MAX_LABELS
+ dropDependentLabels
+ instance : ToString Label
+ mathlibLabelData

You can run this locally as follows
## summary with just the declaration names:
./scripts/declarations_diff.sh <optional_commit>

## more verbose report:
./scripts/declarations_diff.sh long <optional_commit>

The doc-module for script/declarations_diff.sh contains some details about this script.


No changes to technical debt.

You can run this locally as

./scripts/technical-debt-metrics.sh pr_summary
  • The relative value is the weighted sum of the differences with weight given by the inverse of the current value of the statistic.
  • The absolute value is the relative value divided by the total sum of the inverses of the current values (i.e. the weighted average of the differences).

@github-actions github-actions bot added the CI Modifies the continuous integration setup or other automation label Jan 16, 2026
@joneugster joneugster force-pushed the eugster/autolabel-improvements branch from 8e5fb0a to 062eb43 Compare January 16, 2026 22:37
@joneugster joneugster changed the title feat(scripts/autolabel): allow multiple labels, aboid labels of dependent topic areas feat(scripts/autolabel): allow multiple labels, avoid labels of dependent topic areas Jan 16, 2026
Co-authored-by: damiano <[email protected]>
* The `label` field is the actual GitHub label name.
Array of all topic labels which are used in Mathlib.
Note: Since Lean does not know reflection, this needs to be updated manually!
Copy link
Collaborator

@adomani adomani Jan 17, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about we add a test that at least notices if the lists are not in sync? What is below works and assumes that the two lists are exactly equal (not just up to permutations, although we could factor that in as well).

open Lean in
run_cmd
  let some (.inductInfo labels) := (← getEnv).find? ``Label | throwError "Unreachable"
  let labelNames := labels.ctors.filterMap (·.components.getLast?) |>.toArray
  let some (.defnInfo dinfo) := (← getEnv).find? ``mathlibLabels | throwError "Unreachable"
  let allConstants := dinfo.value.getUsedConstants
  let constants := allConstants.filterMap fun n =>
    if n.components.dropLast.getLast? == some `Label then n.components.getLast? else none
  if labelNames != constants then
    logWarning m!"The available Labels is out of sync with the labels listed in \
    {.ofConstName ``mathlibLabels}.\n\
    Please keep them in sync!"

@grunweg grunweg added the awaiting-author A reviewer has asked the author a question or requested changes. label Jan 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting-author A reviewer has asked the author a question or requested changes. CI Modifies the continuous integration setup or other automation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants