Skip to content

Add deterministic partial-port audit - #111

Closed
Vilin97 wants to merge 3 commits into
mainfrom
codex/partial-port-audit
Closed

Vilin97 wants to merge 3 commits into
mainfrom
codex/partial-port-audit

Conversation

@Vilin97

@Vilin97 Vilin97 commented May 19, 2026 •

Copy link
Copy Markdown
Collaborator

Adds a deterministic CI check for the porting failure mode where an import only includes a small slice of the upstream Lean project.

The audit runs on content PRs, reads the project source from LeanPool/projects.yml, clones the upstream source.github_repo, and compares imported Lean file names plus non-comment LOC against upstream with a 10% tolerance. It reports the largest unmatched upstream files so the PR author can either port them or explicitly justify the scope.

Local checks:

  • cd python && uv run ruff check
  • cd python && uv run ruff format --check
  • cd python && uv run --group test pytest tests/test_partial_port_audit.py

Copilot AI review requested due to automatic review settings May 19, 2026 07:01

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR adds a new Python-based CI audit to detect “partial port” failure modes where a LeanPool project imports only a small slice of its declared upstream GitHub repository, by comparing imported Lean filenames (normalized) and non-comment LOC against the upstream checkout with a tolerance threshold, and reporting the largest missing upstream files.

Changes:

  • Add lean_pool.partial_port_audit CLI + supporting dataclasses to compute imported vs upstream Lean stats and emit findings.
  • Add pytest coverage for comment-stripping LOC counting, filename normalization, and suspicious/acceptable import scenarios.
  • Add a GitHub Actions workflow that runs the audit on content PRs affecting LeanPool Lean files or projects.yml.

Fit: good_fit
Level: undergraduate
Branch: repository tooling / CI
Mode: theory_building
Obscure problem: false
Code quality: 4/5
Significance: Helps maintain repository integrity by automatically flagging likely-incomplete upstream ports and surfacing actionable missing-file hints.
Verdict: request_changes

Actionable findings:

  • The audit currently won’t run when only LeanPool/projects.yml changes (despite the workflow triggering on that), so the intended check is skipped for metadata-only content PRs.
  • The “deterministic” claim is undermined by cloning upstream default-branch HEAD (time-dependent), and the workflow currently doesn’t enforce locked Python dependency resolution.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
python/lean_pool/partial_port_audit.py Implements the upstream-vs-imported comparison logic and CLI.
python/tests/test_partial_port_audit.py Adds unit tests for LOC counting, stem normalization, and finding logic.
.github/workflows/partial-port-audit.yml Wires the audit into CI for content PRs.

Comment on lines +123 to +131
def touched_prefixes(paths: list[str]) -> set[str]:
"""Return top-level LeanPool project prefixes touched by a diff."""
prefixes: set[str] = set()
for path in paths:
parts = path.split("/")
if len(parts) == 2 and parts[0] == "LeanPool" and parts[1].endswith(".lean"):
prefixes.add(parts[1].removesuffix(".lean"))
elif len(parts) >= 3 and parts[0] == "LeanPool":
prefixes.add(parts[1])
Comment on lines +210 to +217
def clone_upstream(repo: str, clone_root: Path) -> Path | None:
"""Clone ``repo`` under ``clone_root`` and return the checkout path."""
target = clone_root / repo.replace("/", "__")
if target.exists():
shutil.rmtree(target)
process = subprocess.run(
["git", "clone", "--depth=1", f"https://github.com/{repo}.git", str(target)],
check=False,

- name: Sync Python dependencies
working-directory: python
run: uv sync
@Vilin97

Vilin97 commented May 19, 2026

Copy link
Copy Markdown
Collaborator Author

/profile

@Vilin97 Vilin97 closed this May 19, 2026
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.

2 participants