Repository navigation
fix(watch): quick-scan Markdown that detect() classifies as a paper (#4750) - #4751
jaimemartinez wants to merge 2 commits into
Conversation
…raphify-Labs#4750) A .md/.txt whose opening text matches enough _PAPER_SIGNALS (an arXiv id, "arxiv", an Abstract heading) is classified as `paper`, and the AST-only rebuild behind `graphify update` and the hooks read only the `code` and `document` buckets. Such notes got zero nodes, silently, while an otherwise identical file kept its heading structure. Feed the `paper` bucket through the same AST-extractor filter as documents. Binary papers (PDF) have no AST extractor and stay out; a paper that already has a semantic layer is still excluded from the quick-scan by the Graphify-Labs#1915 gate, so nothing is double-represented.
|
Thanks for the pull request, @jaimemartinez. A maintainer will review it soon. Want to talk it through while it is in review? Come join us on our Discord server. For longer-form discussion there is also GitHub Discussions. A couple of things that speed up review: make sure the test suite passes on Python 3.10 and 3.13, and that the change keeps extraction deterministic. |
There was a problem hiding this comment.
Graphify reviewed this change.
No issues found by static checks — no coupling regressions or blocking issues in the code graph. That is not the same as safe to merge: see what was not checked.
Not checked: tests were not run; formal verification proved 0 of 1 changed function(s) (1 not verified).
Formal verification. PR-changed functions: 0/1 verified (0 proven, 0 may-equivalent, 0 distinguished) · 1 not verified (1 unsupported).
Not verified on this run: \_rebuild\_code (unsupported).
Graphify review — findings
Fixes AST-only rebuilds giving zero nodes to Markdown/text files that detect() reclassifies as papers (e.g. notes quoting an arXiv abstract). _rebuild_code now runs the same doc quick-scan over the paper bucket as over document, and the _get_extractor filter still keeps PDFs and other binary papers out. Adds a regression test (#4750) covering a paper-classified .md, a plain .md, and a PDF.
No blocking issues surfaced.
Analysis details — impact, health, verification
Impact & health
Graphify review
Impact — 799 functions depend on the 505 functions this change touches.
Health — this change adds coupling hotspots:
- worse:
_rebuild_code()— 188 callers, 60 callees
Verification — 799 functions in the blast radius were not formally verified this run (proofs are advisory here).
Gate & verification
graphify gate
PASS — objectively clean (no health regressions, tests not run — proofs not run this pass (advisory)). Grounded, not self-assessed.
Advisory (not blocking):
- verification_scope: 570 function(s) in the blast radius were not formally verified this run
Test selection
Test selection
26 of 453 test file(s) selected (6%) via static blast radius.
tests/test_cache_stale_import_target.py— impacttests/test_compact_graph_json.py— impacttests/test_elixir_import_resolution.py— impacttests/test_elixir_qualified_calls.py— impacttests/test_elixir_unqualified_call_scope.py— impacttests/test_export_direction.py— impacttests/test_external_stub_endpoints.py— impacttests/test_incremental_unscanned_placeholders.py— impacttests/test_java_member_calls.py— impacttests/test_kotlin_grammar.py— impacttests/test_labeling.py— impacttests/test_language_override_lifecycle.py— impacttests/test_lost_saved_semantic_nodes.py— impacttests/test_markdown_code_spans.py— impacttests/test_no_cluster_undeclared_endpoints.py— impacttests/test_pr10_watch_overrides.py— impacttests/test_python_inherited_method_calls.py— impacttests/test_python_property_reads.py— impacttests/test_python_pytest_fixture_receivers.py— impacttests/test_rust_use_trees.py— impacttests/test_skill_persisted_scan_options.py— impacttests/test_solidity_inherited_calls.py— impacttests/test_terraform_modules.py— impacttests/test_watch.py— impact, changed-testtests/test_watch_identity_cache.py— impacttests/test_watch_manifest_location.py— impact
Selection is safe under the controlled-regression assumption; always-run tests + a periodic full run are the backstops. Advisory — it never changes the check verdict.
Formal verification
Could not verify: Could not verify \_rebuild\_code.
The verifier did not have enough to check \_rebuild\_code, so it is saying so rather than guessing. No false assurance is the whole point.
Guarantee: No guarantee either way, this is an honest abstention, not a pass.
Note: Reason: no capturable inputs from the test suite; property tier: nondeterministic output (both versions disagreed with themselves on the witness) — not a behaviour change; a function whose output is not a function of its inputs (random / time / uuid / os.urandom, or state carried across calls) cannot be soundly distinguished by execution, so this tier abstains for the whole function
· 1 more finding(s) on lines outside this diff (see the check run).
nothariharan
left a comment
There was a problem hiding this comment.
Verified this solves #4750. I ran the issue's repro and the semantic-layer interaction against this branch (0c5e62e) and v8 (92741d1).
Issue repro
paper_notes.md v8: 0 nodes -> this PR: 3 nodes
plain_notes.md v8: 3 nodes -> this PR: 3 nodes
Exit 0, no warning, same as the issue.
What I also checked
- A
scan.pdfin the same corpus stays out, because_get_extractorreturnsNonefor PDFs. - The #1915 gate holds: I turned a paper-classified
.mdinto a semantic-backed doc (removed_origin, setfile_type="paper",source_location=None), ranupdateagain, and no AST heading layer was added on top. The semantic nodes were preserved unchanged. tests/test_watch.py -k "paper or quick_scan": 2 passed.- CI is green on 3.10, 3.12, 3.13, and 3.14.
One non-blocking note
The PR body says .md/.txt files are quick-scanned, but only .md, .mdx, and .qmd have an AST extractor in this tree. _get_extractor returns None for .txt, .rst, and .html, so a paper-classified .txt still gets zero nodes on update. That matches the stated invariant ("every text document it can parse") and is not a regression from v8, but the .txt wording is inaccurate.
Optional: add a regression test for the semantic-backed paper case, so the #1915 interaction is locked in and not just the plain-paper case. Not a blocker.
Approving.
…er Markdown (Graphify-Labs#4750) Review follow-up on Graphify-Labs#4751. A paper-classified .md that already has a semantic layer must not gain an AST heading layer now that papers enter the quick-scan; cover the full and incremental rebuild. Also correct the comment: only formats with an AST extractor (.md/.mdx/.qmd today) qualify, so a paper-classified .txt still gets no nodes, as on v8.
|
Thanks for verifying this, @nothariharan. Both points are addressed in daf0be4:
|
bercedev
left a comment
There was a problem hiding this comment.
New test fails on v8 and passes here. test_rebuild_code_prunes_deleted_file_nodes fails in my run too, but it fails the same way on v8, so it's not from this change. Running paper through the existing _get_extractor filter keeps PDFs and .txt out, as the comment says. LGTM.
…4750) Review follow-up on #4751. A paper-classified .md that already has a semantic layer must not gain an AST heading layer now that papers enter the quick-scan; cover the full and incremental rebuild. Also correct the comment: only formats with an AST extractor (.md/.mdx/.qmd today) qualify, so a paper-classified .txt still gets no nodes, as on v8. (cherry picked from commit daf0be4)
|
Landed in v0.9.96, now on PyPI (pip install graphifyy==0.9.96). Markdown that detect() classifies as a paper is quick-scanned. Thanks for the fix, @jaimemartinez. |
What does this PR do?
Fixes #4750 with the reporter's preferred option (1): documents that
detect()classifies aspaperand that have an AST extractor (.md,.mdx,.qmdtoday) now get the same quick-scan as other documents in the AST-only rebuild.classify_filereclassifies a text document aspaperwhen its first 3,000 characters match_PAPER_SIGNAL_THRESHOLDof the_PAPER_SIGNALS(an arXiv id, "arxiv" and an "Abstract" heading are enough)._rebuild_code, the path behindgraphify updateand the git hooks, reads only thecodeanddocumentbuckets. So those notes got zero nodes, with no warning, while a near-identical file kept its heading structure.The change feeds
detected['files']['paper']through the same_get_extractorfilter thatdocumentfiles already go through:.md,.mdx,.qmd) have an AST extractor and are quick-scanned..pdf, and also plain.txt/.rst) stay out, exactly as before. A paper-classified.txtstill gets zero nodes onupdate, as onv8; giving.txtan extractor is out of scope here.graphify . --update— AST-scans Markdown docs, then merges preserved semantic nodes on top #1915 gate, whose nodefile_typeset already includespaper. So a full/graphifybuild that extracted the paper semantically is not double-represented.Type of change
Verification & Invariants
Invariant: an AST-only rebuild represents every text document it can parse, independent of whether
detect()labels itdocumentorpaper. A doc that already has semantic nodes is never quick-scanned on top of them.test_rebuild_code_quick_scans_markdown_classified_as_paper(tests/test_watch.py) builds a corpus with the issue's two files plus a PDF stub. It first asserts the precondition thatpaper_notes.mdlands indetect()'spaperbucket, then checks three things after a full_rebuild_code:paper_notes.mdhas nodes;plain_notes.mdis unchanged;scan.pdfhas none.The test fails on unmodified
v8withpaper-classified Markdown got zero nodes (#4750).test_rebuild_code_does_not_quick_scan_semantic_backed_paper_markdown(full and incremental rebuild, added after review) seeds a semantic layer for a paper-classified.mdand asserts that no AST heading nodes are added on top and the node count is unchanged. I checked that the full-rebuild case fails if the #1915 gate is disabled. The incremental case passes even then, because the incremental path has its own semantic-doc exclusion.Limitations: the classification itself is unchanged. A paper-like
.mdis still labelledpaperindetect()output and still goes through paper handling in the full/graphifypipeline. This PR only stops the AST-only rebuild from dropping it. Options 2 (an opt-out setting) and 3 (a warning) from the issue are not needed once the file is represented.How was this tested?
Windows 11, Python 3.10,
uv sync, onv8at 92741d1.The 2 failures are
test_code_only_update_follows_its_paragraph_and_merges_the_new_function(2 params). They also fail on unmodifiedv8on this machine, and the test doesn't touch this code path.Manual repro from the issue, using
PYTHONHASHSEED=0 python -m graphify update .:plain_notes.md3 nodes,paper_notes.md0;Graphify-specific checklist
uv run python -m tools.skillgen --bless) when changing their source fragments. (not applicable: no skill fragments touched)