Repository navigation
fix(avi-1765): name YAML/JSON document nodes after their file - #257
Merged
Merged
Conversation
A tree-sitter `document` node has no identifier child, so `nodeIdentifier` fell through to `extractIdentifier` and every YAML and JSON file in a corpus shared the node id "" — they collided on merge and one survived for the whole graph. This is the same empty-id collision fixed for Perl `package`, PHP/C# `namespace` and C#/Java fields in the previous commit; the fixture corpus carried no YAML or JSON, so it reported "0 empty-id nodes" and the class looked closed. Rerunning the task 4.4 check on Apache Fineract found it: 92 YAML/JSON files, 1 Document node in the graph. A `document` is its file, so it joins `moduleTypes` and is named after the file like `program` / `source_file`. Tests: two YAML files no longer share a node id, and the empty-id regression guard now covers the yaml and json grammars alongside perl/php/csharp/java/cpp. graphos-test: 1664 examples, 1 failure, 4 pending (82 s), the failure being the unrelated AVI-1440 TypeScript case; run with `--skip "small random graphs"`, the property that does not terminate on main either.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow-up to #256 (already merged). Same defect class, one more node type.
The bug
A tree-sitter
documentnode — the root of every YAML and JSON file — has no identifier child, sonodeIdentifierfell through toextractIdentifierand returnedNothing. That gives the node id"", and since per-file extractions are merged by id, every YAML and JSON file in a corpus collided on that one id and a single node survived for the whole graph.This is exactly the collision #256 fixed for Perl
package, PHP/C#namespaceand C#/Java fields. It was missed because that PR's verification corpus contained only PHP/Perl/C#/Kotlin/Java sources, so it reported "0 empty-id nodes" and the class looked closed.How it was found
Re-running the change's own task 4.4 check against a real repository instead of the hand-made fixture. On Apache Fineract:
Documentnodes ingraph.jsonThe survivor is a docker-compose file; the other 91 are simply absent from the graph.
The fix
A
documentis its file, sodocumentjoinsmoduleTypesand is named after the file likeprogram/source_file. ItskindstaysDocument.Tests
yamlandjsongrammars alongsideperl/php/csharp/java/cpp.graphos-test: 1664 examples, 1 failure, 4 pending (82 s). The failure is the unrelated AVI-1440 TypeScript case. Run with--skip "small random graphs"— see below.Two pre-existing issues this does not address
cabal test alldoes not terminate onmain—BoundedDeltaCommunitySpec.hs:224, "delta update equals full rebuild on small random graphs (property)". Reproduced on baremainwith all branch changes stashed. CI'stestjob on the openspec: bunch-real-projects — dependencies, cap delta, D4 scope #254 merge ran 2h37m before I stopped checking..jsonis in nofecCode/fecDoccategory, so the pipeline never detects JSON files — its grammar anddefaultExtractorsentry are unreachable in a real run. Adding it would change graphs for every repo (lockfiles, fixtures, vendored data), so it wants a deliberate decision rather than a silent inclusion here.Consequence for existing graphs
Any
graph.jsonbuilt before this commit under-represents YAML/JSON. Repos already rebuilt with #256 (Fineract was rebuilt at 15:23 today) need another pass if their YAML/JSON files matter.