fix(generate): skip leading copyright block in import prelude - #467
Merged
kim-em merged 4 commits intoJul 29, 2026
Merged
Conversation
`importPreludeLength` only consumed leading `import` and blank lines, so for source files using Mathlib's copyright-then-import layout it returned 0. `renderChallengeDepsCore` then sliced the body from offset 0 and — on the kept-declarations path, which (unlike the local-imports path) never calls `stripProblemMarkers` — copied the copyright block and `import EvalTools.Markers` into the generated `ChallengeDeps.lean`. The standalone (Mathlib-only) workspace then failed to build with `unknown module prefix 'EvalTools'`. Skip a leading block comment that precedes the first `import` line (nesting-aware), so the copyright header is treated as part of the prelude. Comments after an import are left untouched, so the existing import-first files generate identically (verified: `generate --check` reports no changes on the committed problems; regenerating a copyright- first problem now produces a clean `ChallengeDeps.lean`). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
BoltonBailey
marked this pull request as ready for review
June 25, 2026 00:39
BoltonBailey
marked this pull request as draft
June 25, 2026 01:01
BoltonBailey
marked this pull request as ready for review
June 28, 2026 00:37
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Disclaimer: Claude identified this as an issue as I was asking it to assemble another PR, which included files with both copyright headers and definitional dependencies to the main theorem. I asked Claude to write and PR this fix - it wrote it itself but I have checked it over and it looks OK to me.
My summary is that
importPreludeLengthpreviously has not accounted for the possible presence of a copyright header, and isn't getting any prelude for files that have such a header. This turns out not to cause problems for files that don't rely on defs, but it seems it does for files that do.