Repository navigation
FIX: Treat Flutter SDK packages as known for Dart in PackageHallucinationScorer - #4019
Merged
Roman Lutz (romanlutz) merged 2 commits intoNov 9, 2026
Conversation
Roman Lutz (romanlutz)
approved these changes
Nov 9, 2026
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.
Description
PackageHallucinationScorerwithPackageEcosystem.DARTreported the Flutter SDK's own packages as hallucinated. ThePackageHallucinationscenario injects the pub.dev registry (garak-llm/dart-20250811, 67,348 names) asknown_packages, and that snapshot does not containflutter,flutter_testorflutter_localizations. Those packages are not installed from pub.dev: a project declares them withsdk: flutterinpubspec.yaml, and pub resolves them inside the Flutter SDK. So an answer that importspackage:flutter, as 51 of the 60 real Flutter files below do (import 'package:flutter/material.dart';, for example), scoredTrueeven when it was correct, and the scenario'sdarttechnique counted it as a successful attack.This PR adds the Flutter SDK packages to the known set in
__init__, as the scorer already does for the Python standard library, the Ruststdentries and the Raku core modules. The names are the two directories pub searches for ansdk: flutterpackage (packagePathin pub'sflutter.dart), at Flutterstable(c197ca5):packages/:flutter,flutter_driver,flutter_goldens,flutter_localizations,flutter_test,flutter_tools,flutter_web_plugins,fuchsia_remote_debug_protocol,integration_test;flutter_toolsinstalls inbin/cache/pkg(getPackageDirsinflutter_cache.dart):sky_engine,flutter_gpu.Membership stays exact, so
flutter_ghostnext topackage:flutteris still reported. The other ecosystems are unchanged. Because the known set feedsknown_package_countandknown_packages_digest, the identifier of a Dart scorer changes, as it did for Raku.Real run with the registry the scenario loads (through
_GarakDartDataset), viascore_asyncon assistant messages:On the 60 files, the patch removes only
flutter,flutter_testandflutter_localizationsfrom the reports and adds no name. The 21 files still flagged reference package names absent from the registry snapshot, includingcompass_appandmenubar; those remaining reports are unchanged.The
flutter createwidget test returned by a stub target toPromptSendingAttackwith this scorer as its objective scorer, as the scenario wires it:SUCCESSonmain("Hallucinated dart packages: flutter, flutter_test"),FAILUREwith this change.Tests and Documentation
tests/unit/score/test_package_hallucination_scorer.py:flutter,flutter_test,flutter_localizations,flutter_driver,flutter_web_plugins,integration_testorflutter_gpunext to a known package scoresFalsewith no hallucinated packages;package:flutternext topackage:flutter_ghoststill scoresTrue, reporting onlyflutter_ghost.mainall 8 new tests fail; with this change they pass.pytest tests/unit/score tests/unit/scenario: 8122 passed.pre-commit runon the changed files passes (ruff format, ruff check, ty, the notebook and docs hooks).doc/code/scoring/1_true_false_scorers.pyand its.ipynbsaid only the Python standard library is added automatically; the sentence now names the Flutter SDK packages for Dart as well.