Skip to content

Harden parser, speed up graph ops, add incremental cache#27

Merged
LeTuR merged 1 commit into
mainfrom
improve-gdcruiser
Jul 11, 2026
Merged

Harden parser, speed up graph ops, add incremental cache#27
LeTuR merged 1 commit into
mainfrom
improve-gdcruiser

Conversation

@LeTuR

@LeTuR LeTuR commented Jul 11, 2026

Copy link
Copy Markdown
Contributor

Summary

Correctness, performance, design, and robustness improvements across the analyzer, with 36 new regression tests (176 total, ruff clean).

Parser correctness

  • Strip comments and triple-quoted strings before matching preload/load/extends — commented-out or in-string references no longer create phantom graph edges (which could manufacture false cycles/rule violations).
  • Expanded the builtin class set to cut false "broken inheritance" edges.

Performance

  • get_dependents now uses a lazily-built reverse-adjacency index (was O(V·E) per call, quadratic in the orphan check).
  • Scanner walks the project tree once, bucketing by suffix (was 3 full walks).
  • Tarjan cycle detection converted to an iterative stack — no RecursionError on deep chains.

Design

  • Shared type_label/short_path/to_res_path helpers; deleted the boilerplate Patterns class; formatter registry; DOT/Mermaid label escaping.

Features & robustness

  • Incremental parse cache keyed by mtime+size (--cache / --cache-file); symbol resolution and cycle detection always run fresh so output is identical to an uncached run.
  • Warnings for unknown config keys and bad severity values.
  • Duplicate class_name collisions surfaced as warnings; malformed project.godot and non-UTF-8 files no longer abort the run.

Test plan

  • uv run pytest → 176 passed (36 new: parser edge cases, cache hit/miss/invalidation, dependents index, deep-graph cycles, scanner, output escaping, symbol collisions, malformed input, config semantics).
  • uv run ruff check . → clean.
  • Verified manually: phantom deps gone / real deps kept, deep-chain Tarjan, cache warm-run equals cold-run graph, single-file cache invalidation, config warnings surface on typo'd sections.

@LeTuR
LeTuR enabled auto-merge (rebase) July 11, 2026 10:42
Parser correctness:
- Strip comments and triple-quoted strings before matching preload/load/
  extends so commented-out or in-string references no longer create edges
- Expand builtin class set to cut false "broken inheritance" edges

Performance:
- Lazily build a reverse-adjacency index for get_dependents (was O(V*E))
- Walk the project tree once, bucketing files by suffix
- Convert Tarjan cycle detection to an iterative stack (no RecursionError)

Design:
- Share type_label/short_path/to_res_path helpers; drop the Patterns class
- Dispatch formatters through a registry; escape DOT/Mermaid labels

Features & robustness:
- Incremental parse cache keyed by mtime+size (--cache/--cache-file)
- Warn on unknown config keys and bad severity values
- Surface duplicate class_name collisions; tolerate malformed project.godot
  and non-UTF-8 source files instead of aborting

Adds 36 regression tests (176 total).
@LeTuR
LeTuR force-pushed the improve-gdcruiser branch from 2665ccb to 613abfe Compare July 11, 2026 10:43
@LeTuR
LeTuR merged commit 1db3d7b into main Jul 11, 2026
2 checks passed
@LeTuR
LeTuR deleted the improve-gdcruiser branch July 11, 2026 10:43
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.

1 participant