Skip to content

fix: parse dependency references by their parts - #1

Merged
bryangingechen merged 2 commits into
mainfrom
fix-reference-parsing
Oct 7, 2026
Merged

bryangingechen merged 2 commits into
mainfrom
fix-reference-parsing

Conversation

@bryangingechen

@bryangingechen bryangingechen commented Oct 7, 2026 •

Copy link
Copy Markdown

Fixes three ways the extractor misreads a dependency line. They turned up while comparing it with the parser in leanprover-community/bors-ng#67, which reads the same keywords from PR descriptions so that bors can let linked PRs merge together.

  • A link with no owner or repository (https://github.com//issues/5) was read as a dependency on build(deps-dev): bump eslint-config-prettier from 6.15.0 to 7.0.0 z0al/dependent-issues#5 of this repository, through a stray |\B in the link pattern. GitHub has no such link, so it is no longer read.
  • A link to a repository named issues or pull (https://github.com/owner/issues/issues/5) became owner owner#issues, repository 5 and number NaN, because the first /issues/ was replaced with #. It is now read as owner/issues#5.
  • A keyword that an earlier one starts, as depends on starts depends on:, left : #5 behind after removing the keyword. Splitting that threw a TypeError that failed the whole run. mathlib's keywords don't hit this.

The extractor now takes the reference as what follows the last whitespace in the match (a reference has none), and reads its owner, repository and number with anchored patterns instead of string replacements. Nothing else it reads changes. Run on the same 31 descriptions, this extractor and bors's parser now find the same dependencies in every one; before, they differed on the first two cases above.

Each case has a test that fails without its fix. dist/ is rebuilt and matches a fresh yarn package.

mathlib4's dependent-issues workflow pins 642c46a, so it needs a bump to pick this up.

🤖 Generated with Claude Code

bryangingechen and others added 2 commits October 6, 2026 20:07
The link pattern accepted `\B` in place of `owner/repo`, so
`https://github.com//issues/5` passed, and stripping the URL prefix
then left `z0al#5`, a dependency on issue 5 of this repository. GitHub has
no such link. A link now needs an owner and a repository, as
`owner/repo#5` already does.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The extractor turned each match into `owner/repo#number` with string
replacements, then split it apart again. Two inputs broke this:

- A link to a repository named `issues` or `pull`, such as
  `https://github.com/owner/issues/issues/5`: replacing the first
  `/issues/` with `#` gave `owner#issues/5`, read as owner `owner#issues`,
  repository `5` and number NaN, which the GraphQL lookup rejects.
- A keyword that an earlier one starts, as `depends on` starts
  `depends on:`: removing the keyword from `depends on: z0al#5` left `: z0al#5`,
  and splitting that threw a TypeError that failed the whole run.

The reference is now taken as what follows the last whitespace in the
match (a reference has none), and its owner, repository and number are
read with anchored patterns.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@bryangingechen
bryangingechen merged commit f41637e into main Oct 7, 2026
1 check passed
@bryangingechen
bryangingechen deleted the fix-reference-parsing branch October 7, 2026 00:25
bryangingechen added a commit to leanprover-community/bors-ng that referenced this pull request Oct 7, 2026
…Rs can merge (#67)

On mathlib4, the dependent-issues workflow puts `blocked-by-other-PR` on any PR whose description lists an open dependency (`- [ ] depends on: bors-ng#123`), and mathlib's bors.toml makes that a blocking label. dependent-issues knows nothing about bors bundles, so a PR that tracks its dependencies and is linked or stacked is blocked from merging unless the label is removed manually.

This PR adds a `[dependencies]` table to bors.toml. With it set, bors reads the dependencies from the PR description itself on every check, and blocks while any of them is open and outside the PR's bundle. A bundle lands in one push or not at all, so a dependency in it can't land after the PR that needs it. Note that the description is the source of truth here, and bors doesn't read the label at all (which could be up to 15 minutes out of date, since it's managed by the dependent-issues workflow).

bors now reads every PR's description, and the parser matches dependent-issues exactly using the keywords in bors.toml (leanprover-community/dependent-issues#1 fixes the edge cases where they differed). Where PCRE's regex rules differ from JavaScript's, bors follows JavaScript's: word characters are ASCII only, and matching a keyword in any case never folds a non-ASCII letter into an ASCII one. Deciding what blocks matches dependent-issues too: a closed dependency doesn't block, while an open one, or one GitHub won't show bors, does. bors takes the state of this repo's PRs from its own database, which webhooks keep current, and asks GitHub's issues endpoint about the rest: dependencies in other repositories, and numbers bors has no PR for (e.g. issues). A 404, 410 or 451 there, or a 403 that isn't a rate limit, won't change on a retry, so it is an answer rather than an error. If GitHub can't answer at `r+`, the PR waits, as it does when any other GitHub read fails, unless bors already knows another of its dependencies is open, in which case the `r+` is refused.

Dependencies are checked at `r+` (and again while the PR waits for CI, or when its bundle queues), and once more right before each batch builds, with the bors.toml the batch builds with. The second check catches what changed since `r+`: a description edited, a dependency reopened, or a PR put back in the queue when its batch was split or another PR was cancelled out of it. A PR that now depends on something open and outside its bundle leaves the batch with its bundle, and the comment names the dependency. So does a PR whose dependencies GitHub can't check, since building it could merge it ahead of one; it can be `r+`'d again. The rest of the batch is merged again without them at the next poll. Both checks read the description from GitHub rather than bors's stored copy, which can lag behind. The batch-start check costs one GitHub read per PR, in projects with `[dependencies]` only.

Two gaps remain. A dependency added to the description while its batch is already building isn't caught, since nothing checks between the build starting and the merge. And a PR of this repo that reopens is only seen through its webhook, as for any other PR state bors keeps.

For mathlib, once this is deployed, `blocked-by-other-PR` comes out of `block_labels`, and bors.toml gains:

    [dependencies]
    keywords = ["- [ ] depends on:", "- [x] depends on:"]

The bors.toml change has to land after the deploy, since older bors would ignore the new table and stop blocking on dependencies entirely. The dependent-issues workflow should also get a comment saying bors reads its keywords, so the two are changed together, and its pin bumped to pick up leanprover-community/dependent-issues#1.

🤖 Generated with [Claude Code](https://claude.com/claude-code)
mathlib-bors Bot pushed a commit to leanprover-community/mathlib4 that referenced this pull request Oct 23, 2026
mathlib-bors Bot pushed a commit to leanprover-community/mathlib4 that referenced this pull request Oct 23, 2026
…label (#44572)

Currently, PRs that are labeled with `blocked-by-other-PR` cannot be merged, due to it being in `block_labels` in `bors.toml`. This is an issue for PRs that have been bundled using `bors stack` or `bors link` since if they list their dependencies in the PR, the dependent-issues workflow comes and adds that label. (cf. #42976 (comment) and [this zulip message](https://leanprover.zulipchat.com/#narrow/channel/287929-mathlib4/topic/Stacked.20pull.20requests/near/629173087)).

A new bors feature that should solve this has been deployed (leanprover-community/bors-ng#67). The new `[dependencies]` settings in `bors.toml` tell bors to read dependencies from the PR body with the same keywords as the dependent-issues action, and then bors will ensure that the listed PRs are all merged, closed, or in the same bundle before putting the PR on the queue. This PR contains the adaptations necessary to make use of this feature.

It also includes a bump to the leanprover-community/dependent-issues action to include some parsing fixes: leanprover-community/dependent-issues#1.
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