Skip to content

Quality review + bugfix: v0.3 surface#55

Merged
djankov merged 2 commits into
mainfrom
issue-24-quality-review-bugfix-v0-3-surface
Jun 9, 2026
Merged

Quality review + bugfix: v0.3 surface#55
djankov merged 2 commits into
mainfrom
issue-24-quality-review-bugfix-v0-3-surface

Conversation

@djankov

@djankov djankov commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

Summary

End-of-milestone quality review of the v0.3 surface (field catalogue, linter, pygls LSP, VS Code extension). Every formal gate was already green — ruff check, ruff format --check, mypy --strict, and 2209 tests; the catalogue (102 types / 2614 fields), the linter's zero-false-positive bar on the stock R2026a corpus, and the extension's id/scopeName/launch wiring all hold. An adversarial review across the surface surfaced two real robustness gaps the corpus and feature tests miss, both fixed here with regression coverage, plus hygiene and a coverage close-out:

  • LSP diagnostics path could crash the connection. refresh_diagnostics (the didOpen / didChange path) went straight to diagnostics_for without the _safe wrapper the request handlers use. A buffer nested deep enough to exhaust the recursion limit parses cleanly, so the linter's recursive reference collector walks it and raises RecursionError out of the notification handler — contradicting the module's documented "can never crash the connection" guarantee (the existing "survive malformed input" tests only feed syntax-error buffers). refresh_diagnostics now runs through _safe and publishes an empty list instead.
  • format_edits leaked RecursionError. It caught only (ValueError, TypeError), so the whole-document formatter's RecursionError on a deeply nested expression escaped its documented "yields no edit" contract. It now catches RecursionError too.
  • Hygiene. Removed the #19 / #20 / #21 issue numbers from shipped module docstrings/comments (kept out of source per convention), and corrected the rules.py docstring that claimed nine structural checks — there are eight.
  • Coverage. Closed the four remaining partial branches to 100% line + branch on the v0.3 surface: pragma: no branch on the three grammar-guaranteed is not None guards in the reference collector (unreachable on a clean parse, which is the only path the linter walks), and a test exercising the value_references cache hit.

Out of scope (noted, not changed): the underlying recursion in format() and the reference collector is left intact — the LSP boundary is what must stay up, and rewriting those walkers iteratively is a larger change than this review warrants. A library caller passing a 500-deep nested expression still gets a RecursionError, which is acceptable.

Test plan

  • uv run pytest — 2213 passed (4 new regression tests)
  • uv run pytest --cov=gmat_script — 100% line + branch overall, including catalog.py, lint/, and lsp/
  • uv run mypy — clean (src + tests, strict)
  • uv run ruff check and uv run ruff format --check — clean
  • Catalogue data integrity audited (no missing keys, dangling aliases, or typo'd ref-targets); linter re-confirmed zero ERROR/WARNING findings across the 171-file stock corpus; extension source verified consistent end-to-end

Closes #24

djankov added 2 commits June 8, 2026 21:01
The didOpen / didChange diagnostics path went straight to diagnostics_for
without the _safe wrapper the request handlers use, so a buffer nested deep
enough to exhaust the recursion limit (a clean parse the recursive reference
collector walks) raised RecursionError out of the handler — contradicting the
module's "can never crash the connection" guarantee. Wrap refresh_diagnostics
in _safe so it publishes an empty list instead. format_edits had the same gap:
it caught only (ValueError, TypeError), letting the formatter's RecursionError
escape its documented "yields no edit" contract; catch RecursionError too.

Regression tests cover both: a failing analysis still publishes [], a
pathologically deep document survives didOpen, and format_edits returns no edit
on deep nesting.
Drop the #19 / #20 / #21 issue numbers from the shipped module docstrings and
comments (kept out of source per project convention), and correct the rules
docstring that claimed nine structural checks — there are eight. Close the four
remaining partial branches to 100% line + branch on the v0.3 surface: mark the
three grammar-guaranteed is-not-None guards in the reference collector with
pragma: no branch, and add a test exercising the value_references cache hit.
@djankov djankov marked this pull request as ready for review June 9, 2026 01:05
@djankov djankov merged commit 11bfb1a into main Jun 9, 2026
26 checks passed
@djankov djankov deleted the issue-24-quality-review-bugfix-v0-3-surface branch June 9, 2026 01:05
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.

Quality review + bugfix: v0.3 surface

1 participant