Skip to content

fix: reduce Dart extraction noise - #2249

Open
Overman775 wants to merge 1 commit into
Graphify-Labs:v8from
Overman775:codex/dart-parser-fixes-v2
Open

fix: reduce Dart extraction noise#2249
Overman775 wants to merge 1 commit into
Graphify-Labs:v8from
Overman775:codex/dart-parser-fixes-v2

Conversation

@Overman775

Copy link
Copy Markdown
Contributor

What changed

This PR makes Dart extraction stricter about parser noise. It keeps the current regex-based approach, but avoids creating graph nodes from syntax fragments that are not project entities.

The patch covers a few cases that showed up in real Flutter code:

  • part of 'package:...' files now resolve through pubspec.yaml to the parent file under lib/
  • generated/private names like _ and _$Foo no longer become graph nodes
  • getters and modifiers like String get, bool get, static const, static final are filtered out
  • function types, records, constructor params, and factory params no longer create comma-split labels
  • common Dart SDK types such as FutureOr, Never, MapEntry, Iterator, Comparable, StackTrace, Exception are filtered from noisy type references
  • SDK targets from extension on String/List/Map/Set/Iterable/Future/Stream and SDK typedef targets are filtered as noise
  • SDK Iterable<T> from an extension type implements clause is filtered as noise
  • Dart 3 syntax is covered: records, patterns, class modifiers, extension types, enhanced enums, wildcard _
  • Dart with MyMixin still emits mixes_in

This is not a Dart analyzer rewrite. It only removes false positives that showed up in real projects.

The SDK filter is intentionally conservative. It covers common dart:core and dart:async noise, but does not try to mirror the full Dart SDK. Graphify filters by short name here, so a very broad SDK list could hide project classes with the same names.

Why

The old extractor sometimes treated syntax fragments as project entities. On a real Flutter monorepo I saw nodes like:

_
String get
bool get
static const
String sku, int
mocks_mock_webview_platform_mock

Those nodes are not useful graph facts. They make traversal noisier because they look like real classes, methods, or types.

Real project check

I also ran the extractor against a Flutter monorepo with 1552 Dart files. Extraction errors stayed at 0.

Noise comparison:

item before after
_ labels 211 0
String get labels 114 0
bool get labels 39 0
static const/final labels 49 0
comma-label nodes 49 0
fake file-scoped Mock node 1 0
SDK String/List/Map/Iterable/Future labels 119 0

Most structural relations stayed stable:

relation before after
imports 6066 6066
exports 364 364
inherits 687 687
calls 351 351
navigates 40 40
extends 283 265
implements 580 579

The two drops are intentional. extends drops because SDK targets from ordinary Dart extensions are now filtered; project extension targets still remain. implements drops because one SDK Iterable<T> edge from an extension type is now filtered.

Migration note

If you already have a graph for a Dart or Flutter project, run a forced rebuild once after updating:

graphify . --force

Older graphify-out/graph.json files may already contain the parser-noise nodes removed here. A forced rebuild removes those stale nodes instead of carrying them through an incremental update.

Notes

The new tests focus on regression cases, not every Dart grammar rule. They cover the bugs above plus Dart 3 syntax that previously had a good chance of creating fake graph nodes.

@Overman775
Overman775 force-pushed the codex/dart-parser-fixes-v2 branch from 8638e4a to d149ba6 Compare August 14, 2026 11:19

@graphify-labs graphify-labs Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Graphify reviewed this change.

Worth a look — the grounded gate found no coupling regressions or blocking issues, but 1 advisory finding(s) below merit a look before merge.

Formal verification. No changes could be formally verified in this run.


Graphify review — findings

This PR reworks the Dart extractor (graphify/extractors/dart.py) to add more careful type-name handling and part-file resolution. Key changes include: - A new _resolve_part_parent helper that resolves package: URIs in Dart part of declarations by locating the nearest pubspec.yaml, so part files map to the parent library stem rather than a local path. - A new _clean_type_name helper (plus supporting sets/helpers for SDK "noise" types, declaration modifiers, and balanced-generic stripping) that normalizes type fragments before creating nodes, applied across inheritance, mixins, interfaces, typedefs, extensions, and variable-type relations. - Assorted parsing adjustments such as skipping bare _ names, handling extension type const, and guarding the variable regex against declaration keywords. The large set of touched test files (tests/test_extract, tests/test_dart, and many rationale-numbered tests) indicates accompanying test additions/updates covering these extraction behaviors.

Worth a look

  • _clean_type_name splits on '.' before stripping generics, mangling qualified generic typesgraphify/extractors/dart.py · Escalate · medium
    • agreed by 2 of 2 members but NOT verified (no proof, no reproducing execution) — consensus is not a verdict; needs human review Execution auto-disposal is off for this run; enable it (with sandbox isolation) to have Graphify try to confirm or refute this automatically.
Analysis details — impact, health, verification

Impact & health

Graphify review

Impact — 358 functions depend on the 358 functions this change touches.

Health — this change adds coupling hotspots:

  • worse: extract_dart() — 9 callers, 8 callees

Verification — 358 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: 358 function(s) in the blast radius were not formally verified this run

Formal verification

Could not verify: Could not verify extract\_dart.

The verifier did not have enough to check extract\_dart, 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: parameter `path` is annotated `Path` — outside the synthesizable primitive/collection set

· 1 more finding(s) on lines outside this diff (see the check run).

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