feat(xatu): construct scope graphs and add parser debug output #91

Closed
alexion wants to merge 1 commits from feat/xatu-scope-graph into main
Owner

Summary

  • Construct lexical scope graphs from rnix syntax alongside the lowered rule AST.
  • Keep all rnix access in parser.rs and store the graph in ast::ParsedFile.
  • Add xatu --debug to dump parser representations and parse errors as deterministic JSON without lint diagnostics.
  • Extend the existing Nix fixtures with ordered and unordered declarations for the future ordering rule.
  • Add black-box CLI tests against expected JSON, plus checks for errors and deterministic file ordering.

Construction follows the lexical subset of Néron et al., A Theory of Name Resolution (2015).
Initial coverage targets src/dotfiles/registry.nix.
Unsupported binding constructs remain outside the coverage guarantee.
This change adds no resolver, dependency analysis, ordering rule, or automatic reordering.

Validation

  • bazel test //src/xatu:all — all three targets pass.
  • cargo check -p xatu — passes.
  • cargo clippy -p xatu -- -D warnings — passes.
  • nix run .#fix — passes.
  • Inspect --debug src/dotfiles/registry.nix — no parse errors; 74 scopes, 93 declarations, and 171 references.
  • Verify fixture occurrence ranges against source text and review scope links.

Notes

The CLI skips symlinks, including Bazel runfiles.
Tests copy fixture inputs into TEST_TMPDIR; AGENTS.md records this constraint.
The README documents coverage limits, debug exit codes, and expected-output regeneration.

## Summary - Construct lexical scope graphs from rnix syntax alongside the lowered rule AST. - Keep all rnix access in `parser.rs` and store the graph in `ast::ParsedFile`. - Add `xatu --debug` to dump parser representations and parse errors as deterministic JSON without lint diagnostics. - Extend the existing Nix fixtures with ordered and unordered declarations for the future ordering rule. - Add black-box CLI tests against expected JSON, plus checks for errors and deterministic file ordering. Construction follows the lexical subset of Néron et al., *A Theory of Name Resolution* (2015). Initial coverage targets `src/dotfiles/registry.nix`. Unsupported binding constructs remain outside the coverage guarantee. This change adds no resolver, dependency analysis, ordering rule, or automatic reordering. ## Validation - `bazel test //src/xatu:all` — all three targets pass. - `cargo check -p xatu` — passes. - `cargo clippy -p xatu -- -D warnings` — passes. - `nix run .#fix` — passes. - Inspect `--debug src/dotfiles/registry.nix` — no parse errors; 74 scopes, 93 declarations, and 171 references. - Verify fixture occurrence ranges against source text and review scope links. ## Notes The CLI skips symlinks, including Bazel runfiles. Tests copy fixture inputs into `TEST_TMPDIR`; `AGENTS.md` records this constraint. The README documents coverage limits, debug exit codes, and expected-output regeneration.
alexion added 1 commit 2026-09-24 22:47:35 -04:00
alexion closed this pull request 2026-09-24 22:53:16 -04:00
Author
Owner

Superseded by two focused PRs: #92 adds debug output; #93 adds scope-graph construction on top of #92. Neither replacement rewrites this review history.

Superseded by two focused PRs: #92 adds debug output; #93 adds scope-graph construction on top of #92. Neither replacement rewrites this review history.

Pull request closed

Sign in to join this conversation.
No Reviewers
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: alexion/dev#91