Skip to content

feat: require imported root dependencies in generated workspaces - #8

Merged
kim-em merged 3 commits into
mainfrom
feat/extra-workspace-dependencies
Sep 25, 2026
Merged

kim-em merged 3 commits into
mainfrom
feat/extra-workspace-dependencies

Conversation

@kim-em

@kim-em kim-em commented Sep 25, 2026 •

Copy link
Copy Markdown
Collaborator

This PR lets a generated workspace require packages other than Mathlib. A workspace's lakefile.toml gains a [[require]] for every candidate package whose name is the first component of a module the problem imports (after following repo-local imports), emitted in root order before Mathlib, which stays last so that Lake resolves shared transitive dependencies (batteries, aesop, Qq, ...) from Mathlib's pins. Library callers get the candidates from the root lakefile through loadRootDependencies; CLI requests pass them in a new optional dependencies array, and omitting it keeps every existing version 1 request's output unchanged. Tooling requires such as Cli and lean-eval-generator are never selected because no problem imports them, and non-mathlib requires are only validated once selected: a selected require must be a plain git require with non-empty git and rev, and fields a workspace would not reproduce (subDir, scope, table-valued git, ...) are an error. Require values are TOML-escaped. Workspaces that import only Mathlib render byte-identically to before. renderWorkspace now takes a RootDependencies, a bare DependencySpec coerces to it, and loadRootMathlibDependency is kept. This is needed so lean-eval can add a problem importing TauCeti, for the statement of the classification of finite simple groups.

🤖 Prepared with Claude Code

A problem statement may import a package other than Mathlib, for example
TauCeti for the classification of finite simple groups. Its generated
workspace then needs a `[[require]]` for that package, but the root
lakefile also requires tooling packages (Cli, lean-eval-generator) that
must never leak into a workspace.

`loadRootDependencies` now reads the mathlib pin together with every other
git-pinned root require, and each workspace lakefile requires those whose
name is the first component of a module the workspace imports. Extra
requires come first, in root lakefile order, and Mathlib last: Lake resolves
shared transitive dependencies from the later require, so Mathlib must win.
Workspaces that import only Mathlib render exactly as before, and a bare
`DependencySpec` still coerces to the new `RootDependencies`, so existing
callers of `renderWorkspace` keep compiling.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@kim-em
kim-em force-pushed the feat/extra-workspace-dependencies branch from cf315d2 to eabb0fc Compare September 25, 2026 12:43
kim-em and others added 2 commits September 25, 2026 14:04
The JSON request gains an optional `dependencies` array of extra git pins,
so the CLI path can render workspaces for problems that import packages
other than Mathlib; omitting it keeps every existing version 1 request's
meaning and output. Root requires other than mathlib are now only checked
when a problem selects them, so tooling requires may use any Lake syntax,
and a selected require using fields a workspace would not reproduce
(`subDir`, `scope`, table-valued `git`, ...) is a clear error rather than
being silently dropped. Require values are TOML-escaped, which leaves
ordinary names, URLs and revisions unchanged. The README documents the
selection rule and its limitation for packages whose library root differs
from their package name.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Generation now refuses a root mathlib require carrying fields such as
`subDir` or `scope`, which the emitted `[[require]]` would silently drop,
just as it does for a selected extra require; `loadRootMathlibDependency`
keeps ignoring them as before. CLI requests must use the same problem id
rule as manifests, and the workspace name is emitted as an escaped TOML
string. The README tells consumers to install the root lake-manifest.json
into a generated workspace, so the pruned requires resolve to the same
package revisions as the root workspace.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@kim-em
kim-em merged commit 2de7404 into main Sep 25, 2026
1 check passed
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