Skip to content

Add min-dclr snapshot review skill - #10

Open
junekim623 wants to merge 13 commits into
facebookresearch:mainfrom
junekim623:add-minimal-declaration-review
Open

Add min-dclr snapshot review skill#10
junekim623 wants to merge 13 commits into
facebookresearch:mainfrom
junekim623:add-minimal-declaration-review

Conversation

@junekim623

@junekim623 junekim623 commented Sep 4, 2026

Copy link
Copy Markdown

Summary

  • add a standalone min-dclr skill that refreshes a complete source-to-Lean review checklist on demand
  • keep source interpretation with the agent: it reads the mathematical source, selects the minimal source-facing Lean roots, judges faithfulness and coverage, and writes the full Markdown review
  • delegate only dependency-closure discovery and ordering to autoform declaration-closure, a deterministic CLI backed by Lean's elaborated constant environment
  • build and import explicitly named modules, traverse root types and reachable definition values, and never traverse theorem proof values
  • intersect the exact closure with source declarations added or materially changed since the Git base, including when the Lean root is nested inside a larger repository
  • return dependency edges and a dependency-first topological definitions order for the agent to preserve in the review
  • disambiguate duplicate declaration names by using Lean's imported module metadata to select the exact source occurrence
  • fail closed when the requested modules do not build or elaborate instead of substituting an LLM or lexical approximation
  • retain snapshot metadata, source quotations and locators, immutable Lean links, build and axiom checks, partial/missing coverage, omitted pre-existing dependencies, commands, and unresolved evidence in the final Markdown
  • expose $min-dclr through Codex, /autoform:min-dclr through Claude Code, and min-dclr through Muse

Test plan

  • uv run --extra dev pytest -q tests/test_declaration_closure.py tests/test_lean_sources.py tests/test_skill_examples.py::test_min_dclr_refreshes_the_current_snapshot tests/test_plugin_runtime.py (26 passed)
  • uv run autoform declaration-closure --help
  • real Lean-backed closure extraction against the built Cabannes example (resolved and topologically ordered the three-definition closure of CabannesThesis.supervision_nonAmbiguous)
  • exact PR 11 acceptance run in fairinternal/formal-math: 29 roots, 153 reachable changed declarations, 122 non-root definitions, and 567 dependency edges; verified duplicate-name resolution links isQuasicoherent_kernel to its imported production module
  • make lint
  • make check-example
  • skill-creator quick_validate.py skills/min-dclr
  • plugin-creator validate_plugin.py .
  • make test (540 passed, 1 skipped; the unrelated test_cas_acquire_race_has_exactly_one_winner fails under the local Git environment)

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Sep 4, 2026
@junekim623 junekim623 changed the title Add minimal declaration review workflow Add snapshot declaration review skill Sep 4, 2026
@junekim623 junekim623 changed the title Add snapshot declaration review skill Add min-dclr snapshot review skill Sep 4, 2026
Address review feedback on the declaration-closure CLI.

Links: a nested Lean root produced GitHub URLs missing the repository
prefix, so every link 404'd. Carry the prefix on ClosureReport and apply
it to urls while paths stay relative to the Lean root.

Snapshot scope: git status always reports the whole repository, so
unrelated work elsewhere in a monorepo marked the snapshot dirty and
suppressed all links. Scope the check to the Lean root.

Private roots: Lean mangles private names, so looking roots up by the
name the caller typed raised an uncaught KeyError. Match on the display
name and fail with a DeclarationClosureError when a root is unresolved.

Base revision: a two-dot diff against a branch tip reported base-branch
commits as changes. Resolve --base through its merge base with HEAD.

Deletions: only added diff lines were considered, so removing a
structure field left it out of the "exact" closure. Attribute
zero-added-line hunks to the declarations on either side of the seam.

Axioms: an introduced axiom landed in neither definitions nor theorems
and vanished from the checklist. Report it as reviewable.

Also read untracked files with --full-name so they match the
repository-relative paths git diff reports, accept ? and ! in Lean
names, escape non-identifier name components in the generated driver,
and skip the redundant source scan when building links.
The command ran `lake build` and only then asked whether the checkout
was dirty, so an artifact it had just generated — a regenerated
lake-manifest.json — marked the snapshot uncommitted and suppressed
every permalink. The tool degraded its own output.

Read the snapshot before the build, and judge it on *.lean sources
alone. A link addresses one line in one source file, so a rebuilt
manifest, a regenerated site, or work on another project in the same
repository cannot move it.

Decide pinning per declaration rather than per snapshot. A url is
emitted whenever that declaration's own file matches HEAD, so a review
taken mid-edit keeps immutable links for every untouched file instead
of losing all of them; dirty still reports the overall snapshot for
labeling.

Reuse the ignored-directory set that index_project already applies, so
vendored sources under .lake cannot dirty a snapshot in projects that
do not gitignore them.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Meta Open Source bot.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant