Skip to content

detect() already tracks unclassified files; nothing surfaces them, so a 260-file Lean 4 repo reports as a successful run #3511

Closed

Description

@ahpxna

Reproduce (public repo, 3 commands, no API key)

git clone --depth 1 https://github.com/leanprover-community/batteries.git
cd batteries
graphify update .

Result on batteries @ 3b4ce082, graphify 0.9.58:

[graphify watch] Rebuilt: 18 nodes, 13 edges, 7 communities
Code graph updated.

Exit code 0. The 18 nodes come from 4 shell scripts and 2 README files. All
260 .lean files are absent
, and the run says nothing about them.

GRAPH_REPORT.md then states:

## Corpus Check
- 11 files · ~7,795 words
- Verdict: corpus is large enough that graph structure adds value.

For a repository whose actual content is 260 Lean files, that verdict is
describing four shell scripts.

The data is already there

This is the part that makes it cheap to fix. detect() already computes and
returns the list:

>>> from graphify.detect import detect
>>> r = detect(Path("batteries"))
>>> sorted(r.keys())
['files', 'graphifyignore_patterns', 'ignored', 'needs_graph',
 'pruned_noise_dirs', 'scan_root', 'skipped_sensitive', 'total_files',
 'total_words', 'unclassified', 'walk_errors']

>>> r["total_files"]
22
>>> len(r["unclassified"])
268
>>> collections.Counter(Path(x).suffix for x in r["unclassified"]).most_common(3)
[('.lean', 260), ('.toml', 3), ('', 4)]

unclassified holds 268 entries, 260 of them .lean. Nothing downstream reads
it: it does not reach GRAPH_REPORT.md, and graph.json has no field for it.

So this is not a missing computation. It is a missing three lines of display.

Suggested fix (not Lean-specific)

Surfacing unclassified would make the gap visible for every unsupported
language at once:

  • scan summary line — unclassified: 268 files (top: .lean 260, .toml 3)
  • GRAPH_REPORT.md Corpus Check — same line, next to the file/word counts
  • graph.json — "unclassified_files": {"count": 268, "by_extension": {".lean": 260, ...}}

No change to graph topology, no new dependency, and it turns a silent drop into
a number the user can act on. A Verdict: line that knows 268 files were
skipped can also stop asserting the corpus is well covered.

Why .lean is unclassified (for reference)

Verified in source on v8 @ 23f2ffa, not inferred from behaviour:

  • graphify/detect.py → CODE_EXTENSIONS holds 100+ suffixes; .lean is not
    among them.
  • graphify/detect.py → DOC_EXTENSIONS is
    {.md .mdx .qmd .skill .txt .rst .html .yaml .yml}; .lean is not there either.
  • pyproject.toml declares 31 tree-sitter-* grammars. There is no
    tree-sitter-lean to add — pypi.org/pypi/tree-sitter-lean/json and
    pypi.org/pypi/tree-sitter-lean4/json both return HTTP 404.

Not classifying .lean is correct behaviour for an unsupported language. The
reporting is the bug.

Separate question: should graphify parse Lean 4?

Raising it here rather than as a PR, because it does not fit the extractor
pattern in ARCHITECTURE.md and the architecture call is yours. Step 4 of
"Adding a new language extractor" is "Add the tree-sitter package to
pyproject.toml dependencies"; for Lean there is no such package, so any Lean
support would be the project's first non-tree-sitter code extractor — a
precedent rather than a patch.

I wrote a standalone Lean 4 extractor as prior art. It emits graphify's
documented extraction schema and build_from_json() consumes it unchanged. It
is deliberately two-layered so the trustworthy half is separable:

layer method confidence
module / import / declaration literal match on source after comments and string literals are blanked (nested /- -/, --, "…") exact
declaration → declaration uses identifier match against the declared-symbol table, resolved through the enclosing namespace and open, local binders excluded INFERRED, or AMBIGUOUS when more than one declaration matches

On a 445-file Lean corpus it produced 4,068 nodes and 19,804 edges in about two
seconds. One number that may be worth knowing if you take this on: excluding
locally bound names (∀/fun/intro/obtain, and header binder groups) from
resolution removed 4,589 false uses edges — 19% of the edge set — and
moved the hub list from single binder letters to the corpus's real concepts.
Before that fix the top "god nodes" were j, I, A, S.

Happy to open a PR for the reporting fix above if you want it; the extractor I
would only submit if a regex-layer extractor is a direction you want at all.

Environment

  • graphify 0.9.58, installed via uv tool install 'graphifyy[leiden,svg,pdf,office,watch]'
  • Python 3.10.12, Linux aarch64
  • repo v8 @ 23f2ffa; reproduction repo batteries @ 3b4ce082

Activity

  1. ahpxna commented on Sep 12, 2026

    @ahpxna
    Author

    Correction to my own issue text, before anyone acts on it.

    I wrote "Nothing downstream reads it". That is wrong. cli.py does read
    detection["unclassified"] and prints a [graphify extract] N file(s) not classified ... line — added in #1692. I missed it because I reproduced with
    graphify update, which does not go through that path.

    The accurate statement is narrower:

    Everything else in the issue stands, including the batteries reproduction —
    that run used graphify update, so it is a reproduction of the rebuild-path gap
    specifically. Apologies for the overstatement.

    PR opened against v8 for the rebuild path and the report line.

  2. added a commit that references this issue on Sep 12, 2026
    cd85522
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions