Codebase intelligence for AI and humans: code health scores, auto-generated docs, git analytics, dead code detection, and architectural decisions via MCP.
Python aicode-complexitycode-healthcode-intelligencecode-qualitydead-codedeveloper-toolsdocumentationgit-analyticsmcpopen-sourcepythonrefactoringstatic-analysistechnical-debt
feat(tools): knowledge-graph validation harness with pinned 38-repo matrix (#404)
Swati Ahujaef3b436feea1
diff --git a/scripts/kg_validate/baselines/aeson.json b/scripts/kg_validate/baselines/aeson.jsonnew file mode 100644index 000000000..d46db1302--- /dev/null+++ b/scripts/kg_validate/baselines/aeson.json@@ -0,0 +1,76 @@+{+ "repo": "aeson",+ "smells": [+ {+ "code": "catchall_layer",+ "message": "Test holds 76% of layered nodes",+ "severity": "WARN"+ },+ {+ "code": "module_oversized",+ "message": "JSONTestSuite/test_parsing has 319 files with subdirs (window 120)",+ "severity": "WARN"+ }+ ],+ "stats": {+ "by_language": {+ "haskell": {+ "edges_per_file": 3.81,+ "files": 129,+ "import_edges": 491,+ "import_support": "partial",+ "orphan_files": 2,+ "orphan_ratio": 0.016,+ "resolution_rate": 0.774+ },+ "markdown": {+ "edges_per_file": 0.0,+ "files": 1,+ "import_edges": 0,+ "import_support": "none",+ "orphan_files": 1,+ "orphan_ratio": 1.0,+ "resolution_rate": null+ },+ "shell": {+ "edges_per_file": 0.0,+ "files": 3,+ "import_edges": 0,+ "import_support": "none",+ "orphan_files": 3,+ "orphan_ratio": 1.0,+ "resolution_rate": null+ }+ },+ "dominant_language": "haskell",+ "entry_points": [],+ "modules": {+ "count": 7,+ "max_size": 319,+ "min_size": 5,+ "names": [+ "Application",+ "Data",+ "JSONTestSuite/test_parsing",+ "Types",+ "UnitTests",+ "test_transform",+ "tests"+ ]+ },+ "tour_paths": [+ "README.markdown",+ "src/Data/Aeson/Types/FromJSON.hs",+ "src/Data/Aeson/Key.hs",+ "src/Data/Aeson/Types/Internal.hs",+ "src/Data/Aeson/Internal/Prelude.hs",+ "src/Data/Aeson/KeyMap.hs",+ "src/Data/Aeson/Types/Generic.hs",+ "src/Data/Aeson/Decoding/ByteString/Lazy.hs",+ "src/Data/Aeson/Decoding/Conversion.hs",+ "src/Data/Aeson/Internal/Functions.hs",+ "src/Data/Aeson/Internal/Scientific.hs",+ "tests/Options.hs"+ ]+ }+}diff --git a/scripts/kg_validate/baselines/afnetworking.json b/scripts/kg_validate/baselines/afnetworking.jsonnew file mode 100644index 000000000..aa56f6ae6--- /dev/null+++ b/scripts/kg_validate/baselines/afnetworking.json@@ -0,0 +1,65 @@+{+ "repo": "afnetworking",+ "smells": [+ {+ "code": "catchall_layer",+ "message": "Application holds 70% of layered nodes",+ "severity": "WARN"+ }+ ],+ "stats": {+ "by_language": {+ "cpp": {+ "edges_per_file": 0.0,+ "files": 31,+ "import_edges": 0,+ "import_support": "full",+ "orphan_files": 31,+ "orphan_ratio": 1.0,+ "resolution_rate": null+ },+ "objectivec": {+ "edges_per_file": 0.0,+ "files": 49,+ "import_edges": 0,+ "import_support": "none",+ "orphan_files": 49,+ "orphan_ratio": 1.0,+ "resolution_rate": null+ },+ "swift": {+ "edges_per_file": 1.5,+ "files": 4,+ "hint_edges": {+ "same_module": 1+ },+ "import_edges": 6,+ "import_support": "full",+ "orphan_files": 0,+ "orphan_ratio": 0.0,+ "resolution_rate": 0.167+ }+ },+ "dominant_language": "objectivec",+ "entry_points": [],+ "modules": {+ "count": 4,+ "max_size": 85,+ "min_size": 4,+ "names": [+ "Application",+ "Config",+ "Data",+ "Test"+ ]+ },+ "tour_paths": [+ "README.md",+ "AFNetworking/AFNetworking.h",+ "UIKit+AFNetworking/AFAutoPurgingImageCache.h",+ "AFNetworking/AFCompatibilityMacros.h",+ "Framework/AFNetworking.h",+ "Tests/Tests/AFAutoPurgingImageCacheTests.m"+ ]+ }+}diff --git a/scripts/kg_validate/baselines/alamofire.json b/scripts/kg_validate/baselines/alamofire.jsonnew file mode 100644index 000000000..e91333c19--- /dev/null+++ b/scripts/kg_validate/baselines/alamofire.json@@ -0,0 +1,62 @@+{+ "repo": "alamofire",+ "smells": [+ {+ "code": "catchall_layer",+ "message": "Application holds 51% of layered nodes",+ "severity": "WARN"+ }+ ],+ "stats": {+ "by_language": {+ "javascript": {+ "edges_per_file": 0.0,+ "files": 6,+ "import_edges": 0,+ "import_support": "full",+ "orphan_files": 6,+ "orphan_ratio": 1.0,+ "resolution_rate": null+ },+ "swift": {+ "edges_per_file": 4.68,+ "files": 98,+ "hint_edges": {+ "same_module": 277+ },+ "import_edges": 459,+ "import_support": "full",+ "orphan_files": 0,+ "orphan_ratio": 0.0,+ "resolution_rate": 0.704+ }+ },+ "dominant_language": "swift",+ "entry_points": [],+ "modules": {+ "count": 4,+ "max_size": 74,+ "min_size": 7,+ "names": [+ "Application",+ "Config",+ "Service",+ "Test"+ ]+ },+ "tour_paths": [+ "README.md",+ "Source/Core/Session.swift",+ "Source/Core/AFError.swift",+ "Source/Core/Request.swift",+ "Source/Core/HTTPMethod.swift",+ "Source/Core/Protected.swift",+ "Source/Core/URLConvertible+URLRequestConvertible.swift",+ "Source/Features/RequestInterceptor.swift",+ "Source/Core/DataRequest.swift",+ "Source/Features/EventMonitor.swift",+ "Source/Core/HTTPHeaders.swift",+ "Tests/AuthenticationInterceptorTests.swift"+ ]+ }+}diff --git a/scripts/kg_validate/baselines/args.json b/scripts/kg_validate/baselines/args.jsonnew file mode 100644index 000000000..dcc42fe66--- /dev/null+++ b/scripts/kg_validate/baselines/args.json@@ -0,0 +1,44 @@+{+ "repo": "args",+ "smells": [],+ "stats": {+ "by_language": {+ "dart": {+ "edges_per_file": 2.4,+ "files": 25,+ "import_edges": 60,+ "import_support": "partial",+ "orphan_files": 0,+ "orphan_ratio": 0.0,+ "resolution_rate": 0.817+ }+ },+ "dominant_language": "dart",+ "entry_points": [],+ "modules": {+ "count": 4,+ "max_size": 12,+ "min_size": 4,+ "names": [+ "Application",+ "Config",+ "Service",+ "Test"+ ]+ },+ "tour_paths": [+ "README.md",+ "lib/command_runner.dart",+ "lib/src/arg_parser.dart",+ "lib/src/arg_results.dart",+ "lib/src/arg_parser_exception.dart",+ "lib/src/utils.dart",+ "lib/src/help_command.dart",+ "lib/src/usage_exception.dart",+ "lib/src/option.dart",+ "lib/src/parser.dart",+ "lib/src/allow_anything_parser.dart",+ "test/allow_anything_test.dart"+ ]+ }+}diff --git a/scripts/kg_validate/baselines/argu.json b/scripts/kg_validate/baselines/argu.jsonnew file mode 100644index 000000000..9e35f9788--- /dev/null+++ b/scripts/kg_validate/baselines/argu.json@@ -0,0 +1,63 @@+{+ "repo": "argu",+ "smells": [+ {+ "code": "catchall_layer",+ "message": "Application holds 68% of layered nodes",+ "severity": "WARN"+ }+ ],+ "stats": {+ "by_language": {+ "fsharp": {+ "edges_per_file": 1.96,+ "files": 27,+ "hint_edges": {+ "compile_order": 17+ },+ "import_edges": 53,+ "import_support": "partial",+ "orphan_files": 0,+ "orphan_ratio": 0.0,+ "resolution_rate": 0.623+ },+ "shell": {+ "edges_per_file": 0.0,+ "files": 2,+ "import_edges": 0,+ "import_support": "none",+ "orphan_files": 2,+ "orphan_ratio": 1.0,+ "resolution_rate": null+ }+ },+ "dominant_language": "fsharp",+ "entry_points": [+ "src/Argu/Parsers/Cli.fs"+ ],+ "modules": {+ "count": 3,+ "max_size": 28,+ "min_size": 6,+ "names": [+ "Application",+ "Config",+ "Test"+ ]+ },+ "tour_paths": [+ "README.md",+ "src/Argu/Parsers/Cli.fs",+ "src/Argu/Parsers/Common.fs",+ "src/Argu/ParseResults.fs",+ "src/Argu/UnParsers.fs",+ "src/Argu/PreCompute.fs",+ "src/Argu/UnionArgInfo.fs",+ "src/Argu/ConfigReaders.fs",+ "src/Argu/Utils.fs",+ "src/Argu/Attributes.fs",+ "src/Argu/Types.fs",+ "tests/Argu.Tests/SeparatorAttributeTests.fs"+ ]+ }+}diff --git a/scripts/kg_validate/baselines/chi.json b/scripts/kg_validate/baselines/chi.jsonnew file mode 100644index 000000000..3626408ac--- /dev/null+++ b/scripts/kg_validate/baselines/chi.json@@ -0,0 +1,44 @@+{+ "repo": "chi",+ "smells": [],+ "stats": {+ "by_language": {+ "go": {+ "edges_per_file": 14.06,+ "files": 78,+ "import_edges": 1097,+ "import_support": "full",+ "orphan_files": 1,+ "orphan_ratio": 0.013,+ "resolution_rate": 0.768+ }+ },+ "dominant_language": "go",+ "entry_points": [],+ "modules": {+ "count": 4,+ "max_size": 31,+ "min_size": 3,+ "names": [+ "Application",+ "Config",+ "Middleware",+ "Test"+ ]+ },+ "tour_paths": [+ "README.md",+ "middleware/supress_notfound.go",+ "context.go",+ "chi.go",+ "chain.go",+ "tree.go",+ "mux.go",+ "middleware/compress.go",+ "middleware/route_headers.go",+ "middleware/wrap_writer.go",+ "middleware/throttle.go",+ "context_test.go"+ ]+ }+}diff --git a/scripts/kg_validate/baselines/compojure.json b/scripts/kg_validate/baselines/compojure.jsonnew file mode 100644index 000000000..21eb69848--- /dev/null+++ b/scripts/kg_validate/baselines/compojure.json@@ -0,0 +1,46 @@+{+ "repo": "compojure",+ "smells": [+ {+ "code": "catchall_layer",+ "message": "Application holds 61% of layered nodes",+ "severity": "WARN"+ }+ ],+ "stats": {+ "by_language": {+ "clojure": {+ "edges_per_file": 2.33,+ "files": 12,+ "import_edges": 28,+ "import_support": "partial",+ "orphan_files": 1,+ "orphan_ratio": 0.083,+ "resolution_rate": 0.464+ }+ },+ "dominant_language": "clojure",+ "entry_points": [+ "src/compojure/core.clj"+ ],+ "modules": {+ "count": 2,+ "max_size": 11,+ "min_size": 5,+ "names": [+ "Application",+ "Test"+ ]+ },+ "tour_paths": [+ "README.md",+ "src/compojure/core.clj",+ "src/compojure/response.clj",+ "src/compojure/coercions.clj",+ "src/compojure/route.clj",+ "src/compojure/middleware.clj",+ "src/compojure/handler.clj",+ "test/compojure/coercions_test.clj"+ ]+ }+}diff --git a/scripts/kg_validate/baselines/cowlib.json b/scripts/kg_validate/baselines/cowlib.jsonnew file mode 100644index 000000000..f055cac94--- /dev/null+++ b/scripts/kg_validate/baselines/cowlib.json@@ -0,0 +1,56 @@+{+ "repo": "cowlib",+ "smells": [+ {+ "code": "catchall_layer",+ "message": "Application holds 95% of layered nodes",+ "severity": "WARN"+ }+ ],+ "stats": {+ "by_language": {+ "asciidoc": {+ "edges_per_file": 0.0,+ "files": 7,+ "import_edges": 0,+ "import_support": "none",+ "orphan_files": 7,+ "orphan_ratio": 1.0,+ "resolution_rate": null+ },+ "erlang": {+ "edges_per_file": 1.66,+ "files": 29,+ "import_edges": 48,+ "import_support": "partial",+ "orphan_files": 2,+ "orphan_ratio": 0.069,+ "resolution_rate": 0.896+ }+ },+ "dominant_language": "erlang",+ "entry_points": [],+ "modules": {+ "count": 1,+ "max_size": 39,+ "min_size": 39,+ "names": [+ "Application"+ ]+ },+ "tour_paths": [+ "README.asciidoc",+ "src/cow_http_hd.erl",+ "include/cow_inline.hrl",+ "include/cow_parse.hrl",+ "src/cow_date.erl",+ "src/cow_http2.erl",+ "src/cow_cookie.erl",+ "src/cow_http_struct_hd.erl",+ "src/cow_link.erl",+ "src/cow_http.erl",+ "src/cow_http1.erl",+ "src/cow_hpack_dec_huffman_lookup.hrl"+ ]+ }+}diff --git a/scripts/kg_validate/baselines/dfmt.json b/scripts/kg_validate/baselines/dfmt.jsonnew file mode 100644index 000000000..64135f804--- /dev/null+++ b/scripts/kg_validate/baselines/dfmt.json@@ -0,0 +1,62 @@+{+ "repo": "dfmt",+ "smells": [+ {+ "code": "tour_too_short",+ "message": "only 5 steps",+ "severity": "WARN"+ },+ {+ "code": "catchall_layer",+ "message": "Test holds 93% of layered nodes",+ "severity": "WARN"+ },+ {+ "code": "module_oversized",+ "message": "Test has 247 files with subdirs (window 120)",+ "severity": "WARN"+ }+ ],+ "stats": {+ "by_language": {+ "dlang": {+ "edges_per_file": 0.0,+ "files": 256,+ "import_edges": 0,+ "import_support": "none",+ "orphan_files": 256,+ "orphan_ratio": 1.0,+ "resolution_rate": null+ },+ "shell": {+ "edges_per_file": 0.0,+ "files": 4,+ "import_edges": 0,+ "import_support": "none",+ "orphan_files": 4,+ "orphan_ratio": 1.0,+ "resolution_rate": null+ }+ },+ "dominant_language": "dlang",+ "entry_points": [+ "src/dfmt/main.d"+ ],+ "modules": {+ "count": 2,+ "max_size": 247,+ "min_size": 17,+ "names": [+ "Application",+ "Test"+ ]+ },+ "tour_paths": [+ "README.md",+ "dubhash.d",+ "src/dfmt/ast_info.d",+ "release-windows.sh",+ "tests/2d_arrays.d"+ ]+ }+}diff --git a/scripts/kg_validate/baselines/django.json b/scripts/kg_validate/baselines/django.jsonnew file mode 100644index 000000000..da5e14ead--- /dev/null+++ b/scripts/kg_validate/baselines/django.json@@ -0,0 +1,166 @@+{+ "repo": "django",+ "smells": [+ {+ "code": "catchall_layer",+ "message": "Test holds 68% of layered nodes",+ "severity": "WARN"+ },+ {+ "code": "module_oversized",+ "message": "conf/locale has 178 files with subdirs (window 120)",+ "severity": "WARN"+ },+ {+ "code": "module_oversized",+ "message": "tests has 607 files with subdirs (window 120)",+ "severity": "WARN"+ }+ ],+ "stats": {+ "by_language": {+ "javascript": {+ "edges_per_file": 0.02,+ "files": 45,+ "import_edges": 1,+ "import_support": "full",+ "orphan_files": 43,+ "orphan_ratio": 0.956,+ "resolution_rate": 0.0+ },+ "python": {+ "edges_per_file": 3.44,+ "files": 2591,+ "import_edges": 8909,+ "import_support": "full",+ "orphan_files": 602,+ "orphan_ratio": 0.232,+ "resolution_rate": 1.0+ },+ "shell": {+ "edges_per_file": 0.0,+ "files": 2,+ "import_edges": 0,+ "import_support": "none",+ "orphan_files": 2,+ "orphan_ratio": 1.0,+ "resolution_rate": null+ }+ },+ "dominant_language": "python",+ "entry_points": [+ "django/core/handlers/wsgi.py",+ "django/core/handlers/asgi.py",+ "django/__main__.py",+ "django/contrib/admin/views/main.py",+ "django/core/wsgi.py",+ "django/core/asgi.py"+ ],+ "modules": {+ "count": 85,+ "max_size": 607,+ "min_size": 7,+ "names": [+ ".github",+ "API",+ "Application (top-level)",+ "CLI",+ "Middleware",+ "Service",+ "UI",+ "Utility",+ "admin_docs",+ "admin_scripts",+ "admin_views",+ "apps",+ "async",+ "auth_tests",+ "backends",+ "check_framework",+ "composite_pk",+ "conf/locale",+ "contenttypes_tests",+ "contrib/admin",+ "contrib/auth",+ "contrib/contenttypes",+ "contrib/flatpages",+ "contrib/gis",+ "contrib/messages",+ "contrib/postgres",+ "contrib/redirects",+ "contrib/sessions",+ "contrib/sites",+ "contrib/staticfiles",+ "db/backends",+ "db/migrations",+ "db/models",+ "db_functions",+ "decorators",+ "django",+ "django/contrib",+ "django/forms",+ "django/tasks",+ "django/template",+ "django/test",+ "flatpages_tests",+ "foreign_object",+ "forms_tests",+ "generic_views",+ "gis/db",+ "gis_tests",+ "i18n",+ "js_tests",+ "messages_tests",+ "middleware",+ "migrations",+ "migrations/migrations_test_apps",+ "migrations/test_migrations_squashed_complex",+ "migrations/test_migrations_squashed_complex_multi_apps",+ "migrations/test_migrations_squashed_ref_squashed",+ "migrations/test_migrations_squashed_replaced_order",+ "migrations2",+ "model_fields",+ "model_options",+ "postgres_tests",+ "queries",+ "scripts",+ "serializers",+ "servers",+ "sitemaps_tests",+ "sphinx",+ "staticfiles_tests",+ "template_backends",+ "template_tests",+ "template_tests/filter_tests",+ "template_tests/syntax_tests",+ "template_tests/templatetags",+ "test_client",+ "test_client_regress",+ "test_runner",+ "test_runner_apps",+ "test_utils",+ "tests",+ "urlpatterns",+ "urlpatterns_reverse",+ "user_commands",+ "utils_tests",+ "validation",+ "view_tests"+ ]+ },+ "tour_paths": [+ "django",+ "django/__main__.py",+ "django/core/handlers/wsgi.py",+ "django/core/handlers/asgi.py",+ "django/contrib/admin/views/main.py",+ "django/core/wsgi.py",+ "django/middleware/csrf.py",+ "django/conf/project_template/manage.py-tpl",+ "django/db/__init__.py",+ "django/utils/functional.py",+ "django/core/management/commands/makemigrations.py",+ "tests/runtests.py"+ ]+ }+}diff --git a/scripts/kg_validate/baselines/elm-html.json b/scripts/kg_validate/baselines/elm-html.jsonnew file mode 100644index 000000000..21c4c2a1a--- /dev/null+++ b/scripts/kg_validate/baselines/elm-html.json@@ -0,0 +1,43 @@+{+ "repo": "elm-html",+ "smells": [+ {+ "code": "tour_too_short",+ "message": "only 3 steps",+ "severity": "WARN"+ },+ {+ "code": "catchall_layer",+ "message": "Application holds 90% of layered nodes",+ "severity": "WARN"+ }+ ],+ "stats": {+ "by_language": {+ "elm": {+ "edges_per_file": 0.0,+ "files": 5,+ "import_edges": 0,+ "import_support": "none",+ "orphan_files": 5,+ "orphan_ratio": 1.0,+ "resolution_rate": null+ }+ },+ "dominant_language": "elm",+ "entry_points": [],+ "modules": {+ "count": 1,+ "max_size": 9,+ "min_size": 9,+ "names": [+ "Application"+ ]+ },+ "tour_paths": [+ "README.md",+ "src/Html.elm",+ "src/Html/Attributes.elm"+ ]+ }+}diff --git a/scripts/kg_validate/baselines/express.json b/scripts/kg_validate/baselines/express.jsonnew file mode 100644index 000000000..b2588e90f--- /dev/null+++ b/scripts/kg_validate/baselines/express.json@@ -0,0 +1,48 @@+{+ "repo": "express",+ "smells": [+ {+ "code": "catchall_layer",+ "message": "Test holds 59% of layered nodes",+ "severity": "WARN"+ }+ ],+ "stats": {+ "by_language": {+ "javascript": {+ "edges_per_file": 2.03,+ "files": 141,+ "import_edges": 286,+ "import_support": "full",+ "orphan_files": 6,+ "orphan_ratio": 0.043,+ "resolution_rate": 0.185+ }+ },+ "dominant_language": "javascript",+ "entry_points": [],+ "modules": {+ "count": 5,+ "max_size": 91,+ "min_size": 6,+ "names": [+ "API",+ "Application",+ "Config",+ "Service",+ "Test"+ ]+ },+ "tour_paths": [+ "Readme.md",+ "index.js",+ "lib/express.js",+ "lib/application.js",+ "lib/request.js",+ "lib/response.js",+ "lib/utils.js",+ "lib/view.js",+ "test/Route.js"+ ]+ }+}diff --git a/scripts/kg_validate/baselines/fd.json b/scripts/kg_validate/baselines/fd.jsonnew file mode 100644index 000000000..d875e11f1--- /dev/null+++ b/scripts/kg_validate/baselines/fd.json@@ -0,0 +1,59 @@+{+ "repo": "fd",+ "smells": [+ {+ "code": "catchall_layer",+ "message": "Application holds 77% of layered nodes",+ "severity": "WARN"+ }+ ],+ "stats": {+ "by_language": {+ "rust": {+ "edges_per_file": 7.48,+ "files": 23,+ "import_edges": 172,+ "import_support": "full",+ "orphan_files": 0,+ "orphan_ratio": 0.0,+ "resolution_rate": 0.32+ },+ "shell": {+ "edges_per_file": 0.0,+ "files": 4,+ "import_edges": 0,+ "import_support": "none",+ "orphan_files": 4,+ "orphan_ratio": 1.0,+ "resolution_rate": null+ }+ },+ "dominant_language": "rust",+ "entry_points": [+ "src/main.rs"+ ],+ "modules": {+ "count": 2,+ "max_size": 36,+ "min_size": 9,+ "names": [+ "Application",+ "Config"+ ]+ },+ "tour_paths": [+ "README.md",+ "src/main.rs",+ "src/cli.rs",+ "src/fmt/mod.rs",+ "src/exec/mod.rs",+ "src/filter/mod.rs",+ "src/filesystem.rs",+ "src/exit_codes.rs",+ "src/filter/size.rs",+ "src/filter/time.rs",+ "src/dir_entry.rs",+ "tests/tests.rs"+ ]+ }+}diff --git a/scripts/kg_validate/baselines/flask.json b/scripts/kg_validate/baselines/flask.jsonnew file mode 100644index 000000000..8a00c5027--- /dev/null+++ b/scripts/kg_validate/baselines/flask.json@@ -0,0 +1,56 @@+{+ "repo": "flask",+ "smells": [],+ "stats": {+ "by_language": {+ "python": {+ "edges_per_file": 2.43,+ "files": 83,+ "import_edges": 202,+ "import_support": "full",+ "orphan_files": 4,+ "orphan_ratio": 0.048,+ "resolution_rate": 1.0+ },+ "shell": {+ "edges_per_file": 0.0,+ "files": 1,+ "import_edges": 0,+ "import_support": "none",+ "orphan_files": 1,+ "orphan_ratio": 1.0,+ "resolution_rate": null+ }+ },+ "dominant_language": "python",+ "entry_points": [+ "src/flask/app.py",+ "src/flask/sansio/app.py",+ "src/flask/__main__.py"+ ],+ "modules": {+ "count": 3,+ "max_size": 51,+ "min_size": 12,+ "names": [+ "Application",+ "Config",+ "Test"+ ]+ },+ "tour_paths": [+ "README.md",+ "src/flask/app.py",+ "src/flask/sansio/app.py",+ "src/flask/__main__.py",+ "src/flask/cli.py",+ "src/flask/wrappers.py",+ "src/flask/globals.py",+ "src/flask/helpers.py",+ "src/flask/ctx.py",+ "src/flask/signals.py",+ "src/flask/sessions.py",+ "tests/conftest.py"+ ]+ }+}diff --git a/scripts/kg_validate/baselines/fmt.json b/scripts/kg_validate/baselines/fmt.jsonnew file mode 100644index 000000000..0d5465a1b--- /dev/null+++ b/scripts/kg_validate/baselines/fmt.json@@ -0,0 +1,89 @@+{+ "repo": "fmt",+ "smells": [+ {+ "code": "catchall_layer",+ "message": "Test holds 51% of layered nodes",+ "severity": "WARN"+ }+ ],+ "stats": {+ "by_language": {+ "c": {+ "edges_per_file": 1.0,+ "files": 1,+ "import_edges": 1,+ "import_support": "full",+ "orphan_files": 0,+ "orphan_ratio": 0.0,+ "resolution_rate": 1.0+ },+ "cpp": {+ "edges_per_file": 4.03,+ "files": 70,+ "hint_edges": {+ "header_source_pair": 1+ },+ "import_edges": 282,+ "import_support": "full",+ "orphan_files": 2,+ "orphan_ratio": 0.029,+ "resolution_rate": 1.0+ },+ "javascript": {+ "edges_per_file": 0.0,+ "files": 1,+ "import_edges": 0,+ "import_support": "full",+ "orphan_files": 1,+ "orphan_ratio": 1.0,+ "resolution_rate": null+ },+ "python": {+ "edges_per_file": 0.5,+ "files": 6,+ "import_edges": 3,+ "import_support": "full",+ "orphan_files": 2,+ "orphan_ratio": 0.333,+ "resolution_rate": 1.0+ },+ "shell": {+ "edges_per_file": 0.0,+ "files": 1,+ "import_edges": 0,+ "import_support": "none",+ "orphan_files": 1,+ "orphan_ratio": 1.0,+ "resolution_rate": null+ }+ },+ "dominant_language": "cpp",+ "entry_points": [],+ "modules": {+ "count": 4,+ "max_size": 54,+ "min_size": 15,+ "names": [+ "API",+ "Application",+ "Config",+ "Test"+ ]+ },+ "tour_paths": [+ "README.md",+ "src/fmt.cc",+ "src/os.cc",+ "include/fmt/args.h",+ "include/fmt/chrono.h",+ "src/format.cc",+ "include/fmt/color.h",+ "include/fmt/ranges.h",+ "include/fmt/ostream.h",+ "include/fmt/compile.h",+ "include/fmt/std.h",+ "test/base-test.cc"+ ]+ }+}diff --git a/scripts/kg_validate/baselines/glue.json b/scripts/kg_validate/baselines/glue.jsonnew file mode 100644index 000000000..fa5f65035--- /dev/null+++ b/scripts/kg_validate/baselines/glue.json@@ -0,0 +1,52 @@+{+ "repo": "glue",+ "smells": [+ {+ "code": "catchall_layer",+ "message": "Application holds 52% of layered nodes",+ "severity": "WARN"+ }+ ],+ "stats": {+ "by_language": {+ "c": {+ "edges_per_file": 0.0,+ "files": 3,+ "import_edges": 0,+ "import_support": "full",+ "orphan_files": 3,+ "orphan_ratio": 1.0,+ "resolution_rate": null+ },+ "r": {+ "edges_per_file": 0.0,+ "files": 22,+ "import_edges": 0,+ "import_support": "none",+ "orphan_files": 22,+ "orphan_ratio": 1.0,+ "resolution_rate": null+ }+ },+ "dominant_language": "r",+ "entry_points": [],+ "modules": {+ "count": 3,+ "max_size": 28,+ "min_size": 11,+ "names": [+ "Application",+ "Config",+ "Test"+ ]+ },+ "tour_paths": [+ "README.md",+ "R/glue.R",+ "R/color.R",+ "src/glue.c",+ "revdep/issue308-is-environment.R",+ "tests/testthat.R"+ ]+ }+}diff --git a/scripts/kg_validate/baselines/gson.json b/scripts/kg_validate/baselines/gson.jsonnew file mode 100644index 000000000..8040cdc59--- /dev/null+++ b/scripts/kg_validate/baselines/gson.json@@ -0,0 +1,61 @@+{+ "repo": "gson",+ "smells": [],+ "stats": {+ "by_language": {+ "java": {+ "edges_per_file": 7.37,+ "files": 262,+ "hint_edges": {+ "same_package": 143+ },+ "import_edges": 1930,+ "import_support": "full",+ "orphan_files": 8,+ "orphan_ratio": 0.031,+ "resolution_rate": 0.714+ },+ "proto": {+ "edges_per_file": 0.0,+ "files": 4,+ "import_edges": 0,+ "import_support": "none",+ "orphan_files": 4,+ "orphan_ratio": 1.0,+ "resolution_rate": null+ }+ },+ "dominant_language": "java",+ "entry_points": [],+ "modules": {+ "count": 9,+ "max_size": 87,+ "min_size": 3,+ "names": [+ "Application (top-level)",+ "Config",+ "Middleware",+ "gson",+ "proto/test",+ "test",+ "test-shrinker",+ "test/functional",+ "test/internal"+ ]+ },+ "tour_paths": [+ "README.md",+ "gson/src/main/java/com/google/gson/GsonBuilder.java",+ "gson/src/main/java/com/google/gson/stream/JsonReader.java",+ "gson/src/main/java/com/google/gson/stream/JsonWriter.java",+ "gson/src/main/java/com/google/gson/JsonElement.java",+ "gson/src/main/java/com/google/gson/reflect/TypeToken.java",+ "gson/src/main/java/com/google/gson/JsonObject.java",+ "gson/src/main/java/com/google/gson/JsonSerializer.java",+ "gson/src/main/java/com/google/gson/JsonDeserializer.java",+ "gson/src/main/java/com/google/gson/internal/bind/util/ISO8601Utils.java",+ "extras/src/main/java/com/google/gson/interceptors/JsonPostDeserializer.java",+ "gson/src/test/java/com/google/gson/FieldAttributesTest.java"+ ]+ }+}diff --git a/scripts/kg_validate/baselines/httpx.json b/scripts/kg_validate/baselines/httpx.jsonnew file mode 100644index 000000000..15bfe179a--- /dev/null+++ b/scripts/kg_validate/baselines/httpx.json@@ -0,0 +1,52 @@+{+ "repo": "httpx",+ "smells": [+ {+ "code": "catchall_layer",+ "message": "Application holds 53% of layered nodes",+ "severity": "WARN"+ }+ ],+ "stats": {+ "by_language": {+ "python": {+ "edges_per_file": 2.22,+ "files": 60,+ "import_edges": 133,+ "import_support": "full",+ "orphan_files": 3,+ "orphan_ratio": 0.05,+ "resolution_rate": 1.0+ }+ },+ "dominant_language": "python",+ "entry_points": [+ "httpx/_transports/wsgi.py",+ "httpx/_transports/asgi.py"+ ],+ "modules": {+ "count": 3,+ "max_size": 52,+ "min_size": 9,+ "names": [+ "Application",+ "Config",+ "Test"+ ]+ },+ "tour_paths": [+ "README.md",+ "httpx/_transports/wsgi.py",+ "httpx/_transports/asgi.py",+ "httpx/_models.py",+ "httpx/_types.py",+ "httpx/_transports/base.py",+ "httpx/_urls.py",+ "httpx/_exceptions.py",+ "httpx/_utils.py",+ "httpx/_config.py",+ "httpx/_auth.py",+ "tests/conftest.py"+ ]+ }+}diff --git a/scripts/kg_validate/baselines/jason.json b/scripts/kg_validate/baselines/jason.jsonnew file mode 100644index 000000000..bc1b0865b--- /dev/null+++ b/scripts/kg_validate/baselines/jason.json@@ -0,0 +1,56 @@+{+ "repo": "jason",+ "smells": [+ {+ "code": "catchall_layer",+ "message": "Application holds 92% of layered nodes",+ "severity": "WARN"+ },+ {+ "code": "module_oversized",+ "message": "json_test_suite has 325 files with subdirs (window 120)",+ "severity": "WARN"+ }+ ],+ "stats": {+ "by_language": {+ "elixir": {+ "edges_per_file": 1.17,+ "files": 24,+ "import_edges": 28,+ "import_support": "partial",+ "orphan_files": 6,+ "orphan_ratio": 0.25,+ "resolution_rate": 0.893+ }+ },+ "dominant_language": "elixir",+ "entry_points": [],+ "modules": {+ "count": 5,+ "max_size": 325,+ "min_size": 8,+ "names": [+ "Data",+ "Service",+ "Test",+ "formatter_test_suite",+ "json_test_suite"+ ]+ },+ "tour_paths": [+ "README.md",+ "lib/encode.ex",+ "lib/codegen.ex",+ "lib/ordered_object.ex",+ "lib/fragment.ex",+ "lib/jason.ex",+ "lib/decoder.ex",+ "lib/formatter.ex",+ "lib/helpers.ex",+ "lib/sigil.ex",+ "lib/encoder.ex",+ "test/test_helper.exs"+ ]+ }+}diff --git a/scripts/kg_validate/baselines/jsony.json b/scripts/kg_validate/baselines/jsony.jsonnew file mode 100644index 000000000..368a50fe7--- /dev/null+++ b/scripts/kg_validate/baselines/jsony.json@@ -0,0 +1,45 @@+{+ "repo": "jsony",+ "smells": [+ {+ "code": "tour_too_short",+ "message": "only 4 steps",+ "severity": "WARN"+ },+ {+ "code": "catchall_layer",+ "message": "Test holds 91% of layered nodes",+ "severity": "WARN"+ }+ ],+ "stats": {+ "by_language": {+ "nim": {+ "edges_per_file": 0.0,+ "files": 32,+ "import_edges": 0,+ "import_support": "none",+ "orphan_files": 32,+ "orphan_ratio": 1.0,+ "resolution_rate": null+ }+ },+ "dominant_language": "nim",+ "entry_points": [],+ "modules": {+ "count": 2,+ "max_size": 30,+ "min_size": 3,+ "names": [+ "Application",+ "Test"+ ]+ },+ "tour_paths": [+ "README.md",+ "src/jsony.nim",+ "src/jsony/objvar.nim",+ "tests/all.nim"+ ]+ }+}diff --git a/scripts/kg_validate/baselines/kemal.json b/scripts/kg_validate/baselines/kemal.jsonnew file mode 100644index 000000000..6c2184e95--- /dev/null+++ b/scripts/kg_validate/baselines/kemal.json@@ -0,0 +1,49 @@+{+ "repo": "kemal",+ "smells": [+ {+ "code": "tour_too_short",+ "message": "only 4 steps",+ "severity": "WARN"+ },+ {+ "code": "catchall_layer",+ "message": "Application holds 56% of layered nodes",+ "severity": "WARN"+ }+ ],+ "stats": {+ "by_language": {+ "crystal": {+ "edges_per_file": 0.0,+ "files": 75,+ "import_edges": 0,+ "import_support": "none",+ "orphan_files": 75,+ "orphan_ratio": 1.0,+ "resolution_rate": null+ }+ },+ "dominant_language": "crystal",+ "entry_points": [+ "src/kemal/cli.cr"+ ],+ "modules": {+ "count": 4,+ "max_size": 48,+ "min_size": 6,+ "names": [+ "Application",+ "Config",+ "Test",+ "Utility"+ ]+ },+ "tour_paths": [+ "README.md",+ "src/kemal.cr",+ "src/kemal/base_log_handler.cr",+ "spec/spec_helper.cr"+ ]+ }+}diff --git a/scripts/kg_validate/baselines/libuv.json b/scripts/kg_validate/baselines/libuv.jsonnew file mode 100644index 000000000..a695b51a7--- /dev/null+++ b/scripts/kg_validate/baselines/libuv.json@@ -0,0 +1,94 @@+{+ "repo": "libuv",+ "smells": [+ {+ "code": "catchall_layer",+ "message": "Test holds 55% of layered nodes",+ "severity": "WARN"+ }+ ],+ "stats": {+ "by_language": {+ "c": {+ "edges_per_file": 2.03,+ "files": 326,+ "hint_edges": {+ "header_source_pair": 3+ },+ "import_edges": 663,+ "import_support": "full",+ "orphan_files": 32,+ "orphan_ratio": 0.098,+ "resolution_rate": 1.0+ },+ "cpp": {+ "edges_per_file": 1.68,+ "files": 38,+ "hint_edges": {+ "header_source_pair": 10+ },+ "import_edges": 64,+ "import_support": "full",+ "orphan_files": 1,+ "orphan_ratio": 0.026,+ "resolution_rate": 1.0+ },+ "javascript": {+ "edges_per_file": 1.0,+ "files": 1,+ "import_edges": 1,+ "import_support": "full",+ "orphan_files": 0,+ "orphan_ratio": 0.0,+ "resolution_rate": 0.0+ },+ "python": {+ "edges_per_file": 0.0,+ "files": 3,+ "import_edges": 0,+ "import_support": "full",+ "orphan_files": 3,+ "orphan_ratio": 1.0,+ "resolution_rate": null+ },+ "shell": {+ "edges_per_file": 0.0,+ "files": 1,+ "import_edges": 0,+ "import_support": "none",+ "orphan_files": 1,+ "orphan_ratio": 1.0,+ "resolution_rate": null+ }+ },+ "dominant_language": "c",+ "entry_points": [],+ "modules": {+ "count": 6,+ "max_size": 212,+ "min_size": 8,+ "names": [+ "API",+ "Application (top-level)",+ "Config",+ "Test",+ "docs",+ "src"+ ]+ },+ "tour_paths": [+ "README.md",+ "include/uv/unix.h",+ "src/threadpool.c",+ "src/inet.c",+ "include/uv/aix.h",+ "include/uv/bsd.h",+ "include/uv/darwin.h",+ "include/uv/linux.h",+ "include/uv/os390.h",+ "include/uv/posix.h",+ "tools/make_dist_html.py",+ "test/test-loop-time.c"+ ]+ }+}diff --git a/scripts/kg_validate/baselines/mini-taskq.json b/scripts/kg_validate/baselines/mini-taskq.jsonnew file mode 100644index 000000000..43d810e2d--- /dev/null+++ b/scripts/kg_validate/baselines/mini-taskq.json@@ -0,0 +1,45 @@+{+ "repo": "mini-taskq",+ "smells": [+ {+ "code": "catchall_layer",+ "message": "Application holds 82% of layered nodes",+ "severity": "WARN"+ }+ ],+ "stats": {+ "by_language": {+ "python": {+ "edges_per_file": 1.71,+ "files": 7,+ "import_edges": 12,+ "import_support": "full",+ "orphan_files": 0,+ "orphan_ratio": 0.0,+ "resolution_rate": 1.0+ }+ },+ "dominant_language": "python",+ "entry_points": [+ "taskq/cli.py"+ ],+ "modules": {+ "count": 1,+ "max_size": 9,+ "min_size": 9,+ "names": [+ "Application"+ ]+ },+ "tour_paths": [+ "README.md",+ "taskq/cli.py",+ "taskq/queue.py",+ "taskq/task.py",+ "taskq/retry.py",+ "taskq/storage.py",+ "taskq/__init__.py",+ "tests/test_queue.py"+ ]+ }+}diff --git a/scripts/kg_validate/baselines/okio.json b/scripts/kg_validate/baselines/okio.jsonnew file mode 100644index 000000000..1847f3101--- /dev/null+++ b/scripts/kg_validate/baselines/okio.json@@ -0,0 +1,92 @@+{+ "repo": "okio",+ "smells": [+ {+ "code": "catchall_layer",+ "message": "Application holds 71% of layered nodes",+ "severity": "WARN"+ }+ ],+ "stats": {+ "by_language": {+ "cpp": {+ "edges_per_file": 0.0,+ "files": 2,+ "import_edges": 0,+ "import_support": "full",+ "orphan_files": 2,+ "orphan_ratio": 1.0,+ "resolution_rate": null+ },+ "java": {+ "edges_per_file": 8.86,+ "files": 28,+ "hint_edges": {+ "same_package": 1+ },+ "import_edges": 248,+ "import_support": "full",+ "orphan_files": 0,+ "orphan_ratio": 0.0,+ "resolution_rate": 0.363+ },+ "kotlin": {+ "edges_per_file": 6.75,+ "files": 320,+ "hint_edges": {+ "same_package": 177+ },+ "import_edges": 2159,+ "import_support": "full",+ "orphan_files": 28,+ "orphan_ratio": 0.087,+ "resolution_rate": 0.443+ },+ "shell": {+ "edges_per_file": 0.0,+ "files": 2,+ "import_edges": 0,+ "import_support": "none",+ "orphan_files": 2,+ "orphan_ratio": 1.0,+ "resolution_rate": null+ }+ },+ "dominant_language": "kotlin",+ "entry_points": [],+ "modules": {+ "count": 13,+ "max_size": 106,+ "min_size": 5,+ "names": [+ "Application (top-level)",+ "Config",+ "Test",+ "commonMain",+ "docs",+ "jvm/jmh",+ "jvmMain",+ "nativeMain",+ "nonJvmMain",+ "okio-testing-support",+ "okio-wasifilesystem",+ "samples",+ "zlibMain"+ ]+ },+ "tour_paths": [+ "README.md",+ "okio-fakefilesystem/src/commonMain/kotlin/okio/fakefilesystem/FakeFileSystem.kt",+ "okio/src/commonMain/kotlin/okio/Buffer.kt",+ "okio/src/appleMain/kotlin/okio/ByteString.kt",+ "okio/src/commonMain/kotlin/okio/Source.kt",+ "okio/src/commonMain/kotlin/okio/Sink.kt",+ "okio/src/commonMain/kotlin/okio/Path.kt",+ "okio/src/commonMain/kotlin/okio/FileHandle.kt",+ "okio/src/commonMain/kotlin/okio/FileSystem.kt",+ "okio/src/commonMain/kotlin/okio/FileMetadata.kt",+ "okio/src/commonMain/kotlin/okio/Segment.kt",+ "okio/src/jvmTest/kotlin/okio/FileHandleFileSystemTest.kt"+ ]+ }+}diff --git a/scripts/kg_validate/baselines/ordered-collections.json b/scripts/kg_validate/baselines/ordered-collections.jsonnew file mode 100644index 000000000..57bce2116--- /dev/null+++ b/scripts/kg_validate/baselines/ordered-collections.json@@ -0,0 +1,46 @@+{+ "repo": "ordered-collections",+ "smells": [+ {+ "code": "tour_too_short",+ "message": "only 4 steps",+ "severity": "WARN"+ },+ {+ "code": "catchall_layer",+ "message": "Application holds 62% of layered nodes",+ "severity": "WARN"+ }+ ],+ "stats": {+ "by_language": {+ "julia": {+ "edges_per_file": 0.0,+ "files": 13,+ "import_edges": 0,+ "import_support": "none",+ "orphan_files": 13,+ "orphan_ratio": 1.0,+ "resolution_rate": null+ }+ },+ "dominant_language": "julia",+ "entry_points": [],+ "modules": {+ "count": 3,+ "max_size": 16,+ "min_size": 5,+ "names": [+ "Application",+ "Config",+ "Test"+ ]+ },+ "tour_paths": [+ "README.md",+ "src/OrderedCollections.jl",+ "src/dict_sorting.jl",+ "test/runtests.jl"+ ]+ }+}diff --git a/scripts/kg_validate/baselines/plug.json b/scripts/kg_validate/baselines/plug.jsonnew file mode 100644index 000000000..d917c8525--- /dev/null+++ b/scripts/kg_validate/baselines/plug.json@@ -0,0 +1,55 @@+{+ "repo": "plug",+ "smells": [],+ "stats": {+ "by_language": {+ "elixir": {+ "edges_per_file": 1.18,+ "files": 77,+ "import_edges": 91,+ "import_support": "partial",+ "orphan_files": 19,+ "orphan_ratio": 0.247,+ "resolution_rate": 0.989+ },+ "erlang": {+ "edges_per_file": 0.0,+ "files": 1,+ "import_edges": 0,+ "import_support": "partial",+ "orphan_files": 1,+ "orphan_ratio": 1.0,+ "resolution_rate": null+ }+ },+ "dominant_language": "elixir",+ "entry_points": [+ "lib/plug/application.ex"+ ],+ "modules": {+ "count": 4,+ "max_size": 41,+ "min_size": 3,+ "names": [+ "Application",+ "Config",+ "Service",+ "Test"+ ]+ },+ "tour_paths": [+ "README.md",+ "lib/plug/application.ex",+ "lib/plug/router.ex",+ "lib/plug/builder.ex",+ "lib/plug/error_handler.ex",+ "lib/plug/debugger.ex",+ "lib/plug/conn.ex",+ "lib/plug/conn/unfetched.ex",+ "lib/plug.ex",+ "src/plug_multipart.erl",+ "config/config.exs",+ "test/test_helper.exs"+ ]+ }+}diff --git a/scripts/kg_validate/baselines/polly.json b/scripts/kg_validate/baselines/polly.jsonnew file mode 100644index 000000000..2a0f18d7f--- /dev/null+++ b/scripts/kg_validate/baselines/polly.json@@ -0,0 +1,114 @@+{+ "repo": "polly",+ "smells": [+ {+ "code": "catchall_layer",+ "message": "Application holds 57% of layered nodes",+ "severity": "WARN"+ }+ ],+ "stats": {+ "by_language": {+ "csharp": {+ "edges_per_file": 4.24,+ "files": 797,+ "hint_edges": {+ "global_using": 316,+ "partial_class": 1328,+ "same_namespace": 420+ },+ "import_edges": 3377,+ "import_support": "full",+ "orphan_files": 61,+ "orphan_ratio": 0.077,+ "resolution_rate": 0.917+ },+ "fsharp": {+ "edges_per_file": 2.0,+ "files": 1,+ "import_edges": 2,+ "import_support": "partial",+ "orphan_files": 0,+ "orphan_ratio": 0.0,+ "resolution_rate": 0.0+ },+ "javascript": {+ "edges_per_file": 0.0,+ "files": 1,+ "import_edges": 0,+ "import_support": "full",+ "orphan_files": 1,+ "orphan_ratio": 1.0,+ "resolution_rate": null+ }+ },+ "dominant_language": "csharp",+ "entry_points": [],+ "modules": {+ "count": 45,+ "max_size": 51,+ "min_size": 8,+ "names": [+ "Application (top-level)",+ "Config",+ "Polly.Core.Tests/CircuitBreaker",+ "Polly.Core.Tests/Hedging",+ "Polly.Core.Tests/Issues",+ "Polly.Core.Tests/Retry",+ "Polly.Core.Tests/Simmy",+ "Polly.Core.Tests/Utils",+ "Polly.Core/CircuitBreaker",+ "Polly.Core/Fallback",+ "Polly.Core/Hedging",+ "Polly.Core/Retry",+ "Polly.Core/Simmy",+ "Polly.Core/Telemetry",+ "Polly.Core/Timeout",+ "Polly.Specs/Bulkhead",+ "Polly.Specs/Caching",+ "Polly.Specs/CircuitBreaker",+ "Polly.Specs/Helpers",+ "Polly.Specs/RateLimit",+ "Polly.Specs/Retry",+ "Polly/Bulkhead",+ "Polly/Caching",+ "Polly/CircuitBreaker",+ "Polly/NoOp",+ "Polly/RateLimit",+ "Polly/Retry",+ "Polly/Timeout",+ "Polly/Utilities",+ "Polly/Wrap",+ "Utility",+ "bench",+ "docs",+ "samples",+ "src/LegacySupport",+ "src/Polly",+ "src/Polly.Core",+ "src/Polly.Extensions",+ "src/Polly.RateLimiting",+ "src/Snippets",+ "test",+ "test/Polly.Core.Tests",+ "test/Polly.Extensions.Tests",+ "test/Polly.Specs",+ "test/Polly.TestUtils"+ ]+ },+ "tour_paths": [+ "README.md",+ "src/Polly.Core/CircuitBreaker/CircuitBreakerStrategyOptions.TResult.cs",+ "src/LegacySupport/DynamicallyAccessedMembersAttribute.cs",+ "src/Polly.Core/CircuitBreaker/CircuitState.cs",+ "src/Polly.Core/CircuitBreaker/CircuitBreakerManualControl.cs",+ "src/Polly.Core/CircuitBreaker/CircuitBreakerStateProvider.cs",+ "src/Polly.Core/Utils/DefaultPredicates.cs",+ "src/Polly.Core/Utils/ValidationHelper.cs",+ "src/Polly.Core/CircuitBreaker/CircuitBreakerPredicateArguments.cs",+ "src/Polly.Core/CircuitBreaker/BreakDurationGeneratorArguments.cs",+ "src/Polly.Core/CircuitBreaker/OnCircuitClosedArguments.cs",+ "test/Polly.Core.Tests/ResiliencePipelineTTests.Sync.cs"+ ]+ }+}diff --git a/scripts/kg_validate/baselines/pydantic.json b/scripts/kg_validate/baselines/pydantic.jsonnew file mode 100644index 000000000..e42508f1c--- /dev/null+++ b/scripts/kg_validate/baselines/pydantic.json@@ -0,0 +1,96 @@+{+ "repo": "pydantic",+ "smells": [+ {+ "code": "module_oversized",+ "message": "pydantic-core/src has 128 files with subdirs (window 120)",+ "severity": "WARN"+ },+ {+ "code": "module_oversized",+ "message": "pydantic-core/tests has 121 files with subdirs (window 120)",+ "severity": "WARN"+ }+ ],+ "stats": {+ "by_language": {+ "javascript": {+ "edges_per_file": 0.0,+ "files": 5,+ "import_edges": 0,+ "import_support": "full",+ "orphan_files": 5,+ "orphan_ratio": 1.0,+ "resolution_rate": null+ },+ "python": {+ "edges_per_file": 4.03,+ "files": 402,+ "import_edges": 1620,+ "import_support": "full",+ "orphan_files": 11,+ "orphan_ratio": 0.027,+ "resolution_rate": 1.0+ },+ "rust": {+ "edges_per_file": 10.58,+ "files": 125,+ "import_edges": 1323,+ "import_support": "full",+ "orphan_files": 1,+ "orphan_ratio": 0.008,+ "resolution_rate": 0.431+ },+ "shell": {+ "edges_per_file": 0.0,+ "files": 4,+ "import_edges": 0,+ "import_support": "none",+ "orphan_files": 4,+ "orphan_ratio": 1.0,+ "resolution_rate": null+ }+ },+ "dominant_language": "python",+ "entry_points": [+ "pydantic/main.py",+ "pydantic/v1/main.py",+ "pydantic-core/src/lib.rs"+ ],+ "modules": {+ "count": 14,+ "max_size": 128,+ "min_size": 6,+ "names": [+ "API",+ "Application (top-level)",+ "Config",+ "Middleware",+ "Utility",+ "docs",+ "pydantic",+ "pydantic-core",+ "pydantic-core/src",+ "pydantic-core/tests",+ "tests",+ "tests/benchmarks",+ "tests/mypy",+ "tests/typechecking"+ ]+ },+ "tour_paths": [+ "README.md",+ "pydantic/main.py",+ "pydantic/v1/main.py",+ "pydantic-core/src/errors/mod.rs",+ "pydantic-core/src/input/mod.rs",+ "pydantic-core/src/serializers/mod.rs",+ "pydantic-core/src/validators/mod.rs",+ "pydantic-core/src/serializers/type_serializers/mod.rs",+ "pydantic-core/src/common/mod.rs",+ "pydantic-core/src/validators/shared/mod.rs",+ "pydantic-core/src/lib.rs",+ "tests/conftest.py"+ ]+ }+}diff --git a/scripts/kg_validate/baselines/repowise-main.json b/scripts/kg_validate/baselines/repowise-main.jsonnew file mode 100644index 000000000..088019861--- /dev/null+++ b/scripts/kg_validate/baselines/repowise-main.json@@ -0,0 +1,127 @@+{+ "repo": "repowise-main",+ "smells": [],+ "stats": {+ "by_language": {+ "javascript": {+ "edges_per_file": 0.0,+ "files": 1,+ "import_edges": 0,+ "import_support": "full",+ "orphan_files": 1,+ "orphan_ratio": 1.0,+ "resolution_rate": null+ },+ "python": {+ "edges_per_file": 2.87,+ "files": 1002,+ "import_edges": 2875,+ "import_support": "full",+ "orphan_files": 55,+ "orphan_ratio": 0.055,+ "resolution_rate": 1.0+ },+ "shell": {+ "edges_per_file": 0.0,+ "files": 1,+ "import_edges": 0,+ "import_support": "none",+ "orphan_files": 1,+ "orphan_ratio": 1.0,+ "resolution_rate": null+ },+ "typescript": {+ "edges_per_file": 4.23,+ "files": 542,+ "import_edges": 2291,+ "import_support": "full",+ "orphan_files": 1,+ "orphan_ratio": 0.002,+ "resolution_rate": 0.692+ }+ },+ "dominant_language": "python",+ "entry_points": [+ "packages/cli/src/repowise/cli/main.py",+ "packages/core/src/repowise/core/ingestion/resolvers/dotnet/index.py",+ "packages/server/src/repowise/server/app.py"+ ],+ "modules": {+ "count": 56,+ "max_size": 102,+ "min_size": 8,+ "names": [+ "API",+ "Application (top-level)",+ "CLI",+ "Config",+ "Data",+ "Middleware",+ "Test (top-level)",+ "Types",+ "Utility",+ "cli/ui",+ "core/alembic",+ "core/analysis",+ "core/generation",+ "core/ingestion",+ "core/pipeline",+ "core/providers",+ "core/workspace",+ "docs",+ "ingestion/dynamic_hints",+ "ingestion/external_systems",+ "ingestion/extractors",+ "ingestion/framework_edges",+ "ingestion/git_indexer",+ "ingestion/graph",+ "ingestion/languages",+ "ingestion/resolvers",+ "packages",+ "server/services",+ "tests",+ "tests/integration",+ "tests/unit",+ "ui",+ "ui/blast-radius",+ "ui/c4",+ "ui/chat",+ "ui/dashboard",+ "ui/decisions",+ "ui/git",+ "ui/graph",+ "ui/health",+ "ui/ui",+ "ui/wiki",+ "ui/workspace",+ "unit/analysis",+ "unit/cli",+ "unit/dead_code",+ "unit/generation",+ "unit/health",+ "unit/ingestion",+ "unit/persistence",+ "unit/server",+ "unit/test_providers",+ "unit/workspace",+ "web/components",+ "web/lib",+ "website"+ ]+ },+ "tour_paths": [+ "README.md",+ "packages/cli/src/repowise/cli/main.py",+ "packages/types/src/index.ts",+ "packages/ui/src/c4/index.ts",+ "packages/ui/src/health/index.ts",+ "packages/core/src/repowise/core/ingestion/resolvers/dotnet/index.py",+ "packages/ui/src/shared/file-card/index.ts",+ "packages/core/src/repowise/core/persistence/models.py",+ "packages/web/src/lib/api/types.ts",+ "packages/ui/src/settings/index.ts",+ "packages/server/src/repowise/server/app.py",+ "tests/conftest.py"+ ]+ }+}diff --git a/scripts/kg_validate/baselines/requests.json b/scripts/kg_validate/baselines/requests.jsonnew file mode 100644index 000000000..d4e950cc9--- /dev/null+++ b/scripts/kg_validate/baselines/requests.json@@ -0,0 +1,43 @@+{+ "repo": "requests",+ "smells": [],+ "stats": {+ "by_language": {+ "python": {+ "edges_per_file": 2.95,+ "files": 37,+ "import_edges": 109,+ "import_support": "full",+ "orphan_files": 3,+ "orphan_ratio": 0.081,+ "resolution_rate": 1.0+ }+ },+ "dominant_language": "python",+ "entry_points": [],+ "modules": {+ "count": 3,+ "max_size": 30,+ "min_size": 18,+ "names": [+ "Application",+ "Config",+ "Test"+ ]+ },+ "tour_paths": [+ "README.md",+ "src/requests/sessions.py",+ "src/requests/cookies.py",+ "src/requests/compat.py",+ "src/requests/models.py",+ "src/requests/_types.py",+ "src/requests/_internal_utils.py",+ "src/requests/structures.py",+ "src/requests/exceptions.py",+ "src/requests/auth.py",+ "src/requests/utils.py",+ "tests/conftest.py"+ ]+ }+}diff --git a/scripts/kg_validate/baselines/roblox-lua-promise.json b/scripts/kg_validate/baselines/roblox-lua-promise.jsonnew file mode 100644index 000000000..284fe40c8--- /dev/null+++ b/scripts/kg_validate/baselines/roblox-lua-promise.json@@ -0,0 +1,46 @@+{+ "repo": "roblox-lua-promise",+ "smells": [+ {+ "code": "tour_too_short",+ "message": "only 4 steps",+ "severity": "WARN"+ },+ {+ "code": "catchall_layer",+ "message": "Application holds 81% of layered nodes",+ "severity": "WARN"+ }+ ],+ "stats": {+ "by_language": {+ "luau": {+ "edges_per_file": 0.67,+ "files": 3,+ "import_edges": 2,+ "import_support": "partial",+ "orphan_files": 0,+ "orphan_ratio": 0.0,+ "resolution_rate": 0.5+ }+ },+ "dominant_language": "luau",+ "entry_points": [+ "lib/init.lua"+ ],+ "modules": {+ "count": 1,+ "max_size": 17,+ "min_size": 17,+ "names": [+ "Application"+ ]+ },+ "tour_paths": [+ "README.md",+ "lib/init.lua",+ "runTests.server.lua",+ "lib/init.spec.lua"+ ]+ }+}diff --git a/scripts/kg_validate/baselines/scopt.json b/scripts/kg_validate/baselines/scopt.jsonnew file mode 100644index 000000000..4a2818375--- /dev/null+++ b/scripts/kg_validate/baselines/scopt.json@@ -0,0 +1,56 @@+{+ "repo": "scopt",+ "smells": [],+ "stats": {+ "by_language": {+ "markdown": {+ "edges_per_file": 0.0,+ "files": 16,+ "import_edges": 0,+ "import_support": "none",+ "orphan_files": 16,+ "orphan_ratio": 1.0,+ "resolution_rate": null+ },+ "scala": {+ "edges_per_file": 1.79,+ "files": 29,+ "hint_edges": {+ "same_package": 23+ },+ "import_edges": 52,+ "import_support": "partial",+ "orphan_files": 7,+ "orphan_ratio": 0.241,+ "resolution_rate": 0.577+ }+ },+ "dominant_language": "scala",+ "entry_points": [],+ "modules": {+ "count": 4,+ "max_size": 24,+ "min_size": 3,+ "names": [+ "Application",+ "Config",+ "Test",+ "Utility"+ ]+ },+ "tour_paths": [+ "README.md",+ "shared/src/main/scala/scopt/ORunner.scala",+ "shared/src/main/scala/scopt/OptionDef.scala",+ "shared/src/main/scala/scopt/RenderingMode.scala",+ "shared/src/main/scala/scopt/OEffect.scala",+ "shared/src/main/scala/scopt/OParserSetup.scala",+ "shared/src/main/scala/scopt/Validation.scala",+ "shared/src/main/scala-2.12/scopt/Seq.scala",+ "shared/src/main/scala/scopt/OParser.scala",+ "project/Dependencies.scala",+ "shared/src/main/scala/scopt/OptionParser.scala",+ "js/src/test/scala/scopt/SpecUtilPlatform.scala"+ ]+ }+}diff --git a/scripts/kg_validate/baselines/sexplib.json b/scripts/kg_validate/baselines/sexplib.jsonnew file mode 100644index 000000000..a969fecdb--- /dev/null+++ b/scripts/kg_validate/baselines/sexplib.json@@ -0,0 +1,38 @@+{+ "repo": "sexplib",+ "smells": [],+ "stats": {+ "by_language": {+ "ocaml": {+ "edges_per_file": 0.0,+ "files": 54,+ "import_edges": 0,+ "import_support": "none",+ "orphan_files": 54,+ "orphan_ratio": 1.0,+ "resolution_rate": null+ }+ },+ "dominant_language": "ocaml",+ "entry_points": [],+ "modules": {+ "count": 3,+ "max_size": 29,+ "min_size": 6,+ "names": [+ "Application",+ "Service",+ "Test"+ ]+ },+ "tour_paths": [+ "sexplib",+ "src/sexplib.ml",+ "src/conv.ml",+ "num/lib/sexplib_num.ml",+ "unix/lib/sexplib_unix.ml",+ "top/sexplib_install_printers.ml",+ "test/import.ml"+ ]+ }+}diff --git a/scripts/kg_validate/baselines/sinatra.json b/scripts/kg_validate/baselines/sinatra.jsonnew file mode 100644index 000000000..1a75b8f72--- /dev/null+++ b/scripts/kg_validate/baselines/sinatra.json@@ -0,0 +1,64 @@+{+ "repo": "sinatra",+ "smells": [+ {+ "code": "catchall_layer",+ "message": "Test holds 55% of layered nodes",+ "severity": "WARN"+ }+ ],+ "stats": {+ "by_language": {+ "asciidoc": {+ "edges_per_file": 0.0,+ "files": 1,+ "import_edges": 0,+ "import_support": "none",+ "orphan_files": 1,+ "orphan_ratio": 1.0,+ "resolution_rate": null+ },+ "ruby": {+ "edges_per_file": 1.31,+ "files": 147,+ "hint_edges": {+ "spec_mirror": 17+ },+ "import_edges": 192,+ "import_support": "full",+ "orphan_files": 6,+ "orphan_ratio": 0.041,+ "resolution_rate": 0.771+ }+ },+ "dominant_language": "ruby",+ "entry_points": [+ "lib/sinatra/main.rb"+ ],+ "modules": {+ "count": 4,+ "max_size": 94,+ "min_size": 3,+ "names": [+ "Application",+ "Config",+ "Service",+ "Test"+ ]+ },+ "tour_paths": [+ "README.md",+ "lib/sinatra/main.rb",+ "lib/sinatra/base.rb",+ "lib/sinatra.rb",+ "rack-protection/lib/rack/protection.rb",+ "lib/sinatra/show_exceptions.rb",+ "lib/sinatra/indifferent_hash.rb",+ "lib/sinatra/middleware/logger.rb",+ "lib/sinatra/version.rb",+ "rack-protection/lib/rack/protection/version.rb",+ "sinatra-contrib/lib/sinatra/contrib/setup.rb",+ "test/test_helper.rb"+ ]+ }+}diff --git a/scripts/kg_validate/baselines/slim.json b/scripts/kg_validate/baselines/slim.jsonnew file mode 100644index 000000000..80bff2bbd--- /dev/null+++ b/scripts/kg_validate/baselines/slim.json@@ -0,0 +1,48 @@+{+ "repo": "slim",+ "smells": [],+ "stats": {+ "by_language": {+ "php": {+ "edges_per_file": 4.3,+ "files": 125,+ "import_edges": 537,+ "import_support": "full",+ "orphan_files": 6,+ "orphan_ratio": 0.048,+ "resolution_rate": 0.546+ }+ },+ "dominant_language": "php",+ "entry_points": [+ "Slim/App.php"+ ],+ "modules": {+ "count": 6,+ "max_size": 55,+ "min_size": 4,+ "names": [+ "API",+ "Application",+ "Config",+ "Middleware",+ "Test",+ "Types"+ ]+ },+ "tour_paths": [+ "README.md",+ "Slim/App.php",+ "Slim/Interfaces/CallableResolverInterface.php",+ "Slim/Interfaces/RouteCollectorInterface.php",+ "Slim/Interfaces/RouteResolverInterface.php",+ "Slim/Interfaces/MiddlewareDispatcherInterface.php",+ "Slim/Middleware/RoutingMiddleware.php",+ "Slim/Routing/RouteResolver.php",+ "Slim/Routing/RouteCollectorProxy.php",+ "Slim/Middleware/BodyParsingMiddleware.php",+ "Slim/Handlers/Strategies/RequestResponse.php",+ "tests/AppTest.php"+ ]+ }+}diff --git a/scripts/kg_validate/baselines/task.json b/scripts/kg_validate/baselines/task.jsonnew file mode 100644index 000000000..fb3d027de--- /dev/null+++ b/scripts/kg_validate/baselines/task.json@@ -0,0 +1,93 @@+{+ "repo": "task",+ "smells": [+ {+ "code": "catchall_layer",+ "message": "Application holds 81% of layered nodes",+ "severity": "WARN"+ },+ {+ "code": "module_oversized",+ "message": "testdata has 171 files with subdirs (window 120)",+ "severity": "WARN"+ }+ ],+ "stats": {+ "by_language": {+ "go": {+ "edges_per_file": 17.22,+ "files": 122,+ "import_edges": 2101,+ "import_support": "full",+ "orphan_files": 2,+ "orphan_ratio": 0.016,+ "resolution_rate": 0.778+ },+ "javascript": {+ "edges_per_file": 0.0,+ "files": 1,+ "import_edges": 0,+ "import_support": "full",+ "orphan_files": 1,+ "orphan_ratio": 1.0,+ "resolution_rate": null+ },+ "shell": {+ "edges_per_file": 0.0,+ "files": 3,+ "import_edges": 0,+ "import_support": "none",+ "orphan_files": 3,+ "orphan_ratio": 1.0,+ "resolution_rate": null+ },+ "typescript": {+ "edges_per_file": 2.38,+ "files": 8,+ "import_edges": 19,+ "import_support": "full",+ "orphan_files": 1,+ "orphan_ratio": 0.125,+ "resolution_rate": 0.211+ }+ },+ "dominant_language": "go",+ "entry_points": [+ "cmd/release/main.go",+ "cmd/sleepit/sleepit.go",+ "cmd/task/task.go"+ ],+ "modules": {+ "count": 11,+ "max_size": 171,+ "min_size": 3,+ "names": [+ "Application (top-level)",+ "CLI",+ "Config",+ "Service",+ "Test",+ "taskfile",+ "testdata",+ "testdata/dotenv",+ "testdata/includes",+ "var_inheritance/v3",+ "website"+ ]+ },+ "tour_paths": [+ "README.md",+ "cmd/release/main.go",+ "cmd/sleepit/sleepit.go",+ "cmd/task/task.go",+ "errors/errors.go",+ "errors/error_taskfile_decode.go",+ "errors/errors_task.go",+ "errors/errors_taskfile.go",+ "errors/errors_taskrc.go",+ "internal/env/env.go",+ "internal/deepcopy/deepcopy.go",+ "init_test.go"+ ]+ }+}diff --git a/scripts/kg_validate/baselines/typst.json b/scripts/kg_validate/baselines/typst.jsonnew file mode 100644index 000000000..bb07f4ae7--- /dev/null+++ b/scripts/kg_validate/baselines/typst.json@@ -0,0 +1,98 @@+{+ "repo": "typst",+ "smells": [+ {+ "code": "catchall_layer",+ "message": "Application holds 84% of layered nodes",+ "severity": "WARN"+ }+ ],+ "stats": {+ "by_language": {+ "javascript": {+ "edges_per_file": 0.0,+ "files": 2,+ "import_edges": 0,+ "import_support": "full",+ "orphan_files": 2,+ "orphan_ratio": 1.0,+ "resolution_rate": null+ },+ "rust": {+ "edges_per_file": 8.56,+ "files": 400,+ "import_edges": 3423,+ "import_support": "full",+ "orphan_files": 0,+ "orphan_ratio": 0.0,+ "resolution_rate": 0.623+ },+ "typescript": {+ "edges_per_file": 3.0,+ "files": 1,+ "import_edges": 3,+ "import_support": "full",+ "orphan_files": 0,+ "orphan_ratio": 0.0,+ "resolution_rate": 0.0+ }+ },+ "dominant_language": "rust",+ "entry_points": [+ "crates/typst-utils/src/lib.rs",+ "crates/typst-library/src/lib.rs",+ "crates/typst-syntax/src/lib.rs",+ "crates/typst-macros/src/lib.rs",+ "crates/typst-pdf/src/lib.rs",+ "crates/typst/src/lib.rs",+ "crates/typst-layout/src/lib.rs",+ "crates/typst-bundle/src/lib.rs"+ ],+ "modules": {+ "count": 25,+ "max_size": 55,+ "min_size": 4,+ "names": [+ "CLI",+ "Config",+ "Test",+ "UI",+ "Utility",+ "crates",+ "docs",+ "typst-eval",+ "typst-html",+ "typst-ide",+ "typst-kit",+ "typst-layout",+ "typst-library/foundations",+ "typst-library/introspection",+ "typst-library/layout",+ "typst-library/loading",+ "typst-library/math",+ "typst-library/model",+ "typst-library/text",+ "typst-library/visualize",+ "typst-macros",+ "typst-pdf",+ "typst-svg",+ "typst-syntax",+ "typst-utils"+ ]+ },+ "tour_paths": [+ "README.md",+ "crates/typst-kit/src/server.rs",+ "crates/typst-cli/src/main.rs",+ "crates/typst-library/src/foundations/mod.rs",+ "crates/typst-library/src/layout/mod.rs",+ "crates/typst-library/src/introspection/mod.rs",+ "crates/typst-utils/src/lib.rs",+ "crates/typst-library/src/visualize/mod.rs",+ "crates/typst-library/src/text/mod.rs",+ "crates/typst-pdf/src/tags/util/mod.rs",+ "crates/typst-layout/src/pages/mod.rs",+ "tests/src/args.rs"+ ]+ }+}diff --git a/scripts/kg_validate/baselines/zig-clap.json b/scripts/kg_validate/baselines/zig-clap.jsonnew file mode 100644index 000000000..6ab3239c7--- /dev/null+++ b/scripts/kg_validate/baselines/zig-clap.json@@ -0,0 +1,47 @@+{+ "repo": "zig-clap",+ "smells": [+ {+ "code": "tour_too_short",+ "message": "only 4 steps",+ "severity": "WARN"+ },+ {+ "code": "catchall_layer",+ "message": "Application holds 78% of layered nodes",+ "severity": "WARN"+ }+ ],+ "stats": {+ "by_language": {+ "zig": {+ "edges_per_file": 0.0,+ "files": 12,+ "import_edges": 0,+ "import_support": "none",+ "orphan_files": 12,+ "orphan_ratio": 1.0,+ "resolution_rate": null+ }+ },+ "dominant_language": "zig",+ "entry_points": [+ ".github/workflows/main.yml"+ ],+ "modules": {+ "count": 2,+ "max_size": 14,+ "min_size": 4,+ "names": [+ "Application",+ "Config"+ ]+ },+ "tour_paths": [+ "README.md",+ "build.zig",+ "clap/args.zig",+ "clap.zig"+ ]+ }+}diff --git a/scripts/kg_validate/fixtures/mini-taskq.bundle b/scripts/kg_validate/fixtures/mini-taskq.bundlenew file mode 100644index 000000000..c7c10f8d6Binary files /dev/null and b/scripts/kg_validate/fixtures/mini-taskq.bundle differdiff --git a/scripts/kg_validate/kg_checks.py b/scripts/kg_validate/kg_checks.pynew file mode 100644index 000000000..8a20dc091--- /dev/null+++ b/scripts/kg_validate/kg_checks.py@@ -0,0 +1,590 @@+"""Pure checks over an exported knowledge-graph.json dict.++Two layers, both side-effect free so they unit-test on synthetic dicts:++- :func:`compute_stats` — per-language graph-quality numbers (edge density,+ resolution rate, orphan ratio). These are the canary metrics: express's+ CommonJS re-export gap showed up as 1.7 imports/file vs chi's 9.7 long+ before any tour smell fired.+- :func:`run_smells` — the smell suite. Ports the original 7 checks from the+ throwaway /tmp inspect.py and adds graph-level ones (edgeless graphs,+ density regression vs a stored baseline, catch-all layers, entry-point+ sanity). Each smell carries a severity: FAIL smells gate, WARN smells+ report.++Thresholds were locked at the project's acceptance gate from the 38-repo+matrix data (each enforced value leaves ~30% headroom past the worst clean+repo of its tier). The degradation-honesty check: a dominant language with+no import support must yield a structural tour — no execution-flow+vocabulary, layers labeled canonical.+"""++from __future__ import annotations++import re+from dataclasses import dataclass, field+from pathlib import PurePosixPath++# --- Enforced thresholds (locked from the 38-repo matrix) -------------------+#+# Density floors (FAIL): dominant-language imports/file below the tier floor.+# full 0.9 — matrix minimum 1.31 (sinatra, post-stdlib-filter honest)+# partial 0.8 — matrix minimum 1.17 (jason) among repos at/above the+# small-repo cutoff+# Repos with fewer than SMALL_REPO_FILES dominant-language files are exempt+# from all three tier gates (edgeless, floor, ceiling): a 3-file repo's+# density is noise, not evidence (roblox-lua-promise 0.67), and a 2-file+# repo with no imports between its files is normal. Same rationale as the+# curation graph-mode small-repo skip; tiny-repo honesty is still covered+# by the degradation_honesty and tour smells.+DENSITY_FLOORS = {"full": 0.9, "partial": 0.8}+SMALL_REPO_FILES = 10+# Orphan-ratio ceilings (FAIL): dominant language only.+# full 0.30 — matrix maximum 0.232 (django: test-heavy, honest)+# partial 0.35 — matrix maximum 0.25 (plug/jason: elixir fully-qualified+# module references need no alias — recorded residual)+ORPHAN_CEILINGS = {"full": 0.30, "partial": 0.35}+# "Graph claims support but is effectively edgeless" — far below the tier+# floors; kept for the message's specificity on totally broken graphs.+EDGELESS_FLOOR = 0.05+DENSITY_REGRESSION_TOLERANCE = 0.15 # >15% drop vs baseline fails; conscious+# baseline updates are the escape hatch — that friction is the feature.+CATCHALL_WARN_FRACTION = 0.50 # one layer holding >50% of layered nodes+# WARN escalates to FAIL when a single layer holds >95% in a repo with at+# least CATCHALL_FAIL_MIN_FILES code files: layering effectively failed.+# Tiny flat repos legitimately approach one layer (cowlib 95.1% at 29 code+# files is exempt via the size gate; dfmt 93% at 256 files passes).+CATCHALL_FAIL_FRACTION = 0.95+CATCHALL_FAIL_MIN_FILES = 30+LAYER_COUNT_MIN, LAYER_COUNT_MAX = 2, 12 # sanity for repos > LAYER_COUNT_MIN_FILES+LAYER_COUNT_MIN_FILES = 30+# --- Curated wiki modules (kg.modules, derive_modules output) ---------------+# Mirrors kg_curation's granularity window and naming invariants so a broken+# derivation fails the matrix before it ships a wiki regen.+MODULE_TARGET_MAX = 120 # split window; flat dirs may honestly exceed (WARN)+MODULE_MIN_FILES = 3 # layers below this legitimately yield no module+MODULE_COUNT_DIVISOR = 8 # module count must stay within [1, code_files/8]+MODULE_GENERIC_FRACTION = 0.60 # segment in >60% of paths = namespace noise+MODULES_EXPECTED_MIN_FILES = 30 # curated repos this big should have modules+TEST_MODULE_MIN_FILES = 30 # Test layers this big should surface test modules++# Execution-flow vocabulary a structural tour must never use ("named like an+# entry file" is the one sanctioned entry phrasing; "import analysis isn't+# supported" / "import resolution is incomplete" are the honesty disclaimers+# and deliberately absent from this list).+FLOW_CLAIM_TERMS = (+ "entry point",+ "imports fan out",+ "imports deep",+ "import path",+ "directly used by the entry",+ "widely-imported",+)++_EXAMPLE_DIRS = {"examples", "_examples", "example", "samples", "sample", "demo", "demos"}+_TEST_DIRS = {"tests", "test", "__tests__", "e2e"}+++@dataclass+class Smell:+ severity: str # "FAIL" | "WARN"+ code: str+ message: str+++@dataclass+class RepoReport:+ repo: str+ stats: dict+ smells: list[Smell] = field(default_factory=list)+ # Full module inventory for the human-review markdown report+ # (--modules-report); deliberately NOT serialized into baselines —+ # stats["modules"] carries the diffable snapshot.+ modules_detail: list[dict] = field(default_factory=list)++ @property+ def failed(self) -> bool:+ return any(s.severity == "FAIL" for s in self.smells)++ def as_dict(self) -> dict:+ return {+ "repo": self.repo,+ "stats": self.stats,+ "smells": [+ {"severity": s.severity, "code": s.code, "message": s.message}+ for s in self.smells+ ],+ }+++def looks_like_test(path: str) -> bool:+ name = PurePosixPath(path).name.lower()+ parts = [p.lower() for p in PurePosixPath(path).parts]+ return (+ name.startswith("test_")+ or name == "conftest.py"+ or ".test." in name+ or ".spec." in name+ or any(p in _TEST_DIRS for p in parts[:-1])+ )+++# ---------------------------------------------------------------------------+# Stats+# ---------------------------------------------------------------------------+++def compute_stats(kg: dict, import_support: dict[str, str] | None = None) -> dict:+ """Per-language graph-quality stats from the exported KG dict.++ ``import_support`` maps language tag -> "full" | "partial" | "none"+ (from the language registry); unknown languages count as "none".+ """+ support = import_support or {}+ file_nodes = [n for n in kg.get("nodes", []) if n.get("type") == "file" and n.get("filePath")]+ lang_by_id = {f"file:{n['filePath']}": (n.get("language") or "unknown") for n in file_nodes}++ by_lang: dict[str, dict] = {}+ for n in file_nodes:+ lang = n.get("language") or "unknown"+ bucket = by_lang.setdefault(+ lang,+ {+ "files": 0,+ "import_edges": 0,+ "internal_targets": 0,+ "external_targets": 0,+ "hint_edges": {},+ "files_with_edges": set(),+ },+ )+ bucket["files"] += 1++ for e in kg.get("edges", []):+ if e.get("type") not in ("imports", "tested_by"):+ continue+ src, dst = e.get("source", ""), e.get("target", "")+ lang = lang_by_id.get(src)+ if lang is None:+ continue+ bucket = by_lang.get(lang)+ if bucket is None:+ continue+ bucket["import_edges"] += 1+ # Convention-pass edges (e.g. hint="same_package") counted separately+ # so declared-import density and synthesised density are diffable.+ hint = e.get("hint")+ if hint:+ bucket["hint_edges"][hint] = bucket["hint_edges"].get(hint, 0) + 1+ if dst.startswith("file:external:"):+ bucket["external_targets"] += 1+ else:+ bucket["internal_targets"] += 1+ if dst in lang_by_id:+ by_lang[lang_by_id[dst]]["files_with_edges"].add(dst)+ bucket["files_with_edges"].add(src)++ out: dict[str, dict] = {}+ for lang, b in sorted(by_lang.items()):+ files = b["files"]+ resolved = b["internal_targets"]+ total_t = b["internal_targets"] + b["external_targets"]+ out[lang] = {+ "files": files,+ "import_edges": b["import_edges"],+ "edges_per_file": round(b["import_edges"] / files, 2) if files else 0.0,+ "resolution_rate": round(resolved / total_t, 3) if total_t else None,+ "orphan_files": files - len(b["files_with_edges"]),+ "orphan_ratio": round((files - len(b["files_with_edges"])) / files, 3)+ if files+ else 0.0,+ "import_support": support.get(lang, "none"),+ }+ if b["hint_edges"]:+ out[lang]["hint_edges"] = dict(sorted(b["hint_edges"].items()))++ dominant = max(out, key=lambda k: out[k]["files"], default=None)+ stats = {"by_language": out, "dominant_language": dominant}++ # Curated wiki module snapshot — lands in baselines so naming or count+ # drift across runs shows up as a reviewable diff, like tour_paths.+ modules = kg.get("modules") or []+ if modules:+ sizes = [len(m.get("nodeIds", [])) for m in modules]+ stats["modules"] = {+ "count": len(modules),+ "names": sorted(m.get("name", "") for m in modules),+ "min_size": min(sizes, default=0),+ "max_size": max(sizes, default=0),+ }+ return stats+++# ---------------------------------------------------------------------------+# Smells+# ---------------------------------------------------------------------------+++def run_smells(+ kg: dict,+ stats: dict,+ baseline: dict | None = None,+) -> list[Smell]:+ smells: list[Smell] = []+ layers = kg.get("layers") or []+ tour = kg.get("tour") or []+ project = kg.get("project") or {}++ ordered = [lyr["name"] for lyr in sorted(layers, key=lambda x: x.get("display_order", 0))]++ # -- original 7 (from /tmp inspect.py) ---------------------------------+ if "Test" in ordered and ordered[-1] != "Test":+ smells.append(Smell("FAIL", "test_layer_not_last", f"layer order: {ordered}"))++ for s in tour[:4]:+ tp = s.get("target_path") or ""+ if "test suite" in (s.get("reason") or "").lower():+ continue # the designated closing stop — short tours put it early+ if s.get("kind") != "overview" and looks_like_test(tp):+ smells.append(+ Smell("FAIL", "test_file_early_in_tour", f"step {s.get('order')} = {tp}")+ )++ for s in tour:+ if "Top of the stack" in (s.get("reason") or ""):+ smells.append(+ Smell("FAIL", "stack_position_reason", f"step {s.get('order')}")+ )++ targets = [s.get("target_path") for s in tour]+ dupes = sorted({t for t in targets if t and targets.count(t) > 1})+ if dupes:+ smells.append(Smell("FAIL", "duplicate_tour_targets", str(dupes)))++ for s in tour:+ tp = s.get("target_path") or ""+ parts = PurePosixPath(tp).parts+ if any(seg.lower() in _EXAMPLE_DIRS for seg in parts[:-1]):+ smells.append(Smell("FAIL", "example_file_in_tour", f"step {s.get('order')} = {tp}"))+ if s.get("kind") == "code" and parts and parts[0].startswith("."):+ smells.append(Smell("FAIL", "dot_dir_file_in_tour", f"step {s.get('order')} = {tp}"))++ if len(tour) < 6:+ smells.append(Smell("WARN", "tour_too_short", f"only {len(tour)} steps"))++ # -- graph-level -------------------------------------------------------+ by_lang = stats.get("by_language", {})+ dominant = stats.get("dominant_language")+ dom = by_lang.get(dominant, {}) if dominant else {}++ # All three dominant-tier gates exempt repos under SMALL_REPO_FILES+ # dominant-language files: a 2-file repo with no imports between its+ # files is normal, not broken — tiny-repo honesty is covered by the+ # degradation_honesty and tour smells instead.+ if (+ dom+ and dom.get("import_support") in ("full", "partial")+ and dom.get("files", 0) >= SMALL_REPO_FILES+ ):+ if dom.get("edges_per_file", 0.0) < EDGELESS_FLOOR:+ smells.append(+ Smell(+ "FAIL",+ "edgeless_graph",+ f"{dominant} declares import_support={dom['import_support']} but "+ f"edges_per_file={dom.get('edges_per_file')}",+ )+ )+ floor = DENSITY_FLOORS[dom["import_support"]]+ if dom.get("edges_per_file", 0.0) < floor:+ smells.append(+ Smell(+ "FAIL",+ "density_floor",+ f"{dominant} ({dom['import_support']}) edges_per_file="+ f"{dom.get('edges_per_file')} < tier floor {floor}",+ )+ )+ ceiling = ORPHAN_CEILINGS[dom["import_support"]]+ if dom.get("orphan_ratio", 0.0) > ceiling:+ smells.append(+ Smell(+ "FAIL",+ "orphan_ceiling",+ f"{dominant} ({dom['import_support']}) orphan_ratio="+ f"{dom.get('orphan_ratio')} > tier ceiling {ceiling}",+ )+ )++ # -- degradation honesty -----------------------------------------------+ if dom and dom.get("import_support") == "none":+ mode = project.get("graph_mode")+ if mode != "structural":+ smells.append(+ Smell(+ "FAIL",+ "degradation_honesty",+ f"{dominant} has import_support=none but graph_mode={mode!r}",+ )+ )+ for s in tour:+ reason = (s.get("reason") or "").lower()+ hit = next((t for t in FLOW_CLAIM_TERMS if t in reason), None)+ if hit:+ smells.append(+ Smell(+ "FAIL",+ "degradation_honesty",+ f"step {s.get('order')} claims flow ({hit!r}): {s.get('reason')!r}",+ )+ )+ for layer in layers:+ if layer.get("order_basis") != "canonical":+ smells.append(+ Smell(+ "FAIL",+ "degradation_honesty",+ f"layer {layer.get('name')} order_basis="+ f"{layer.get('order_basis')!r} on an edgeless graph",+ )+ )++ if baseline:+ base_langs = (baseline.get("stats") or {}).get("by_language", {})+ for lang, cur in by_lang.items():+ prev = base_langs.get(lang)+ if not prev or prev.get("edges_per_file", 0) <= 0:+ continue+ drop = 1.0 - (cur.get("edges_per_file", 0.0) / prev["edges_per_file"])+ if drop > DENSITY_REGRESSION_TOLERANCE:+ smells.append(+ Smell(+ "FAIL",+ "density_regression",+ f"{lang}: {prev['edges_per_file']} -> {cur.get('edges_per_file')} "+ f"imports/file ({drop:.0%} drop)",+ )+ )++ code_file_count = sum(+ b["files"] for lang, b in by_lang.items() if b.get("import_support") != "none"+ ) or sum(b["files"] for b in by_lang.values())+ if layers and code_file_count:+ biggest = max(layers, key=lambda lyr: len(lyr.get("nodeIds", [])))+ frac = len(biggest.get("nodeIds", [])) / max(+ 1, sum(len(lyr.get("nodeIds", [])) for lyr in layers)+ )+ if frac > CATCHALL_FAIL_FRACTION and code_file_count >= CATCHALL_FAIL_MIN_FILES:+ smells.append(+ Smell(+ "FAIL",+ "catchall_layer",+ f"{biggest.get('name')} holds {frac:.0%} of layered nodes "+ f"({code_file_count} code files — layering effectively failed)",+ )+ )+ elif frac > CATCHALL_WARN_FRACTION:+ smells.append(+ Smell(+ "WARN",+ "catchall_layer",+ f"{biggest.get('name')} holds {frac:.0%} of layered nodes",+ )+ )++ total_files = project.get("total_files", 0)+ if (+ total_files > LAYER_COUNT_MIN_FILES+ and layers+ and not (LAYER_COUNT_MIN <= len(layers) <= LAYER_COUNT_MAX)+ ):+ smells.append(+ Smell("WARN", "layer_count", f"{len(layers)} layers for {total_files} files")+ )++ # -- entry-point sanity --------------------------------------------------+ eps = project.get("entry_points") or []+ node_paths = {n.get("filePath") for n in kg.get("nodes", []) if n.get("filePath")}+ for ep in eps:+ if ep not in node_paths:+ smells.append(Smell("FAIL", "entry_point_missing", f"{ep} not in graph"))+ if looks_like_test(ep):+ smells.append(Smell("FAIL", "entry_point_is_test", ep))+ parts = PurePosixPath(ep).parts+ if any(seg.lower() in _EXAMPLE_DIRS for seg in parts[:-1]):+ smells.append(Smell("FAIL", "entry_point_is_example", ep))+ if not eps:+ for s in tour:+ if "An entry point" in (s.get("reason") or ""):+ smells.append(+ Smell(+ "FAIL",+ "entry_claim_without_entry_points",+ f"step {s.get('order')} claims an entry point but entry_points=[]",+ )+ )++ smells.extend(_module_smells(kg, code_file_count))++ return smells+++def _dominant_path_segments(paths: list[str]) -> set[str]:+ """Dir segments in > MODULE_GENERIC_FRACTION of *paths* (namespace noise).++ Mirrors kg_curation's data-driven stripping: ``src``, ``packages``, the+ repo's own package name. A module *named* one of these tells the reader+ nothing.+ """+ n = len(paths)+ if not n:+ return set()+ counts: dict[str, int] = {}+ for p in paths:+ for seg in set(PurePosixPath(p).parts[:-1]):+ counts[seg] = counts.get(seg, 0) + 1+ return {s.lower() for s, c in counts.items() if c / n > MODULE_GENERIC_FRACTION}+++def _module_smells(kg: dict, code_file_count: int) -> list[Smell]:+ """Curated wiki module invariants over the exported ``kg.modules``.++ The derivation's unit tests cover synthetic shapes; these checks catch+ what only real repos surface — Java namespace prefixes leaking into+ names, confetti module counts on flat-package repos, Test layers losing+ their modules on test-heavy codebases.+ """+ smells: list[Smell] = []+ modules = kg.get("modules") or []+ layers = kg.get("layers") or []+ file_paths = {+ n["id"]: n["filePath"]+ for n in kg.get("nodes", [])+ if n.get("type") == "file" and n.get("filePath")+ }++ if not modules:+ # Curated layers without modules = derivation degraded. Tiny repos+ # legitimately yield none (every layer under MODULE_MIN_FILES).+ if layers and code_file_count >= MODULES_EXPECTED_MIN_FILES:+ smells.append(+ Smell(+ "WARN",+ "modules_missing",+ f"curated layers present but no modules for {code_file_count} code files",+ )+ )+ return smells++ # Partition: no file in two modules (coverage is checked per-layer below).+ seen: set[str] = set()+ for m in modules:+ for nid in m.get("nodeIds", []):+ if nid in seen:+ smells.append(+ Smell("FAIL", "module_partition", f"{file_paths.get(nid, nid)} in >1 module")+ )+ return smells # one witness is enough; rest would be noise+ seen.add(nid)++ # Coverage: every layer big enough to module must be fully covered.+ for layer in layers:+ member_files = [nid for nid in layer.get("nodeIds", []) if nid in file_paths]+ if len(member_files) < MODULE_MIN_FILES:+ continue+ missing = [nid for nid in member_files if nid not in seen]+ if missing:+ smells.append(+ Smell(+ "FAIL",+ "module_coverage",+ f"layer {layer.get('name')}: {len(missing)} files in no module "+ f"(e.g. {file_paths.get(missing[0], missing[0])})",+ )+ )++ # Naming invariants: unique, no size suffixes, no generic-only names.+ names = [m.get("name", "") for m in modules]+ ids = [m.get("id", "") for m in modules]+ for label, values in (("module_name_collision", names), ("module_id_collision", ids)):+ dupes = sorted({v for v in values if values.count(v) > 1})+ if dupes:+ smells.append(Smell("FAIL", label, str(dupes)))+ generic = _dominant_path_segments(sorted(file_paths.values()))+ layer_names = {(layer.get("name") or "").lower() for layer in layers}+ for m in modules:+ name = m.get("name", "")+ if not name.strip() or name.strip().lower() in {"(root)", "root"}:+ smells.append(Smell("FAIL", "module_empty_name", repr(name)))+ continue+ if re.search(r"\(\d+\)\s*$", name):+ smells.append(Smell("FAIL", "module_size_suffix", name))+ segs = [s.lower() for s in name.split("/")]+ # Two honest exemptions: layer-named modules (whole-layer fallback —+ # "API" names the API layer even if "api" is also a path segment),+ # and modules whose OWN path offers no informative segment (fixture+ # subtrees that dominate the repo: the raw tail is the best name+ # available, flagging it would demand a name that can't exist).+ path_segs = {s.lower() for s in (m.get("path") or "").split("/") if s}+ had_alternative = bool(path_segs - generic)+ if (+ segs+ and all(s in generic for s in segs)+ and name.lower() not in layer_names+ and had_alternative+ ):+ smells.append(+ Smell("FAIL", "module_generic_name", f"{name!r} is namespace noise only")+ )++ # Granularity: oversized modules are honest only for flat directories.+ for m in modules:+ size = len(m.get("nodeIds", []))+ if size <= MODULE_TARGET_MAX:+ continue+ prefix = m.get("path", "")+ rels = [+ file_paths[nid][len(prefix) + 1 :] if prefix and file_paths[nid].startswith(prefix + "/")+ else file_paths[nid]+ for nid in m.get("nodeIds", [])+ if nid in file_paths+ ]+ if any("/" in r for r in rels):+ smells.append(+ Smell(+ "WARN",+ "module_oversized",+ f"{m.get('name')} has {size} files with subdirs (window {MODULE_TARGET_MAX})",+ )+ )++ # Count bounds: confetti detection ([1, code_files/8] acceptance gate).+ # Small repos are exempt — a 12-file repo with two honest 6-file modules+ # is structure, not confetti; the gate targets matrix-scale repos.+ ceiling = max(1, code_file_count // MODULE_COUNT_DIVISOR)+ if code_file_count >= MODULES_EXPECTED_MIN_FILES and len(modules) > ceiling:+ smells.append(+ Smell(+ "WARN",+ "module_count",+ f"{len(modules)} modules for {code_file_count} code files (ceiling {ceiling})",+ )+ )++ # Test-heavy repos must keep their test modules (user-valued invariant).+ for layer in layers:+ if (layer.get("name") or "").lower() != "test":+ continue+ test_files = [nid for nid in layer.get("nodeIds", []) if nid in file_paths]+ if len(test_files) >= TEST_MODULE_MIN_FILES:+ layer_id = layer.get("id", "")+ if not any(m.get("layerId") == layer_id for m in modules):+ smells.append(+ Smell(+ "WARN",+ "test_modules_missing",+ f"Test layer has {len(test_files)} files but no module",+ )+ )++ return smellsdiff --git a/scripts/kg_validate/matrix.toml b/scripts/kg_validate/matrix.tomlnew file mode 100644index 000000000..1533a650f--- /dev/null+++ b/scripts/kg_validate/matrix.toml@@ -0,0 +1,245 @@+# KG validation matrix — every repo pinned to a commit so baselines and+# regressions are reproducible. Clones live under /tmp/kg-validate (override+# with KG_VALIDATE_DIR). `source` is a git URL or a local path to clone from.+#+# tier: import-support tier of the dominant language (1 = full resolver ++# validated, 2 = resolver never live-validated, 3 = passthrough).++[chi]+source = "https://github.com/go-chi/chi"+sha = "3b171578ca44dfd75ca3c5cbddc7b44c600a7b49"+language = "go"+tier = 1++[django]+source = "https://github.com/django/django"+sha = "a53e02af6d7a07d0367b534f7107a0e2a37e3d34"+language = "python"+tier = 1++[express]+source = "https://github.com/expressjs/express"+sha = "dae209ae6559c29cfca2a1f4414c51d89ea643d5"+language = "javascript"+tier = 1++[fd]+source = "https://github.com/sharkdp/fd"+sha = "f7d4d717c287a7834f8721efc0fa91c51d92afee"+language = "rust"+tier = 1++[flask]+source = "https://github.com/pallets/flask"+sha = "954f5684e4841aad84a8eec7ace7b81a0d3f6831"+language = "python"+tier = 1++[gson]+source = "https://github.com/google/gson"+sha = "004e7a4949e08b430e3c8996998ee5a17ff9423a"+language = "java"+tier = 1++[httpx]+source = "https://github.com/encode/httpx"+sha = "b5addb64f0161ff6bfe94c124ef76f6a1fba5254"+language = "python"+tier = 1++[mini-taskq]+source = "fixtures/mini-taskq.bundle"+sha = "245eb8213b4ac28571d83cb5080a3146548e4324"+language = "python"+tier = 1++[pydantic]+source = "https://github.com/pydantic/pydantic"+sha = "86f6bbfc3597088df757e8a2c40eb04a38699492"+language = "python"+tier = 1++[repowise-main]+source = "."+sha = "413e82905e2d48b8699c7a61c2b98920c2fc555a"+language = "python"+tier = 1++[requests]+source = "https://github.com/psf/requests"+sha = "cd90742ed94d901759e26766197d0ce7c7bd9c8e"+language = "python"+tier = 1++[sinatra]+source = "https://github.com/sinatra/sinatra"+sha = "5236d3459b8b9015e5ce21ddd0c6beb0db4081d4"+language = "ruby"+tier = 1++[typst]+source = "https://github.com/typst/typst"+sha = "07f5f1afca0a037e03911c8b56e8a14742ac2e8d"+language = "rust"+tier = 1++[jason]+source = "https://github.com/michalmuskala/jason"+sha = "4ede42858eb19f80ec9e863aab52df466eab8608"+language = "elixir"+tier = 2++# --- Tier-2 live-validation batch ---++[okio]+source = "https://github.com/square/okio"+sha = "722c8be0043d99b7b08d169b0ae90a24c15267ff"+language = "kotlin"+tier = 1++[scopt]+source = "https://github.com/scopt/scopt"+sha = "9512cd03475c4c6421cd6ab5a588cb3e1bb7b7e8"+language = "scala"+tier = 2++[polly]+source = "https://github.com/App-vNext/Polly"+sha = "e984839b8324a163270f0bc686929a1066de69e0"+language = "csharp"+tier = 1++[fmt]+source = "https://github.com/fmtlib/fmt"+sha = "e6a8751df7a68144952d5b21b0d4a76327b6c9f7"+language = "cpp"+tier = 1++[alamofire]+source = "https://github.com/Alamofire/Alamofire"+sha = "7595cbcf59809f9977c5f6378500de2ad73b7ddb"+language = "swift"+tier = 1++[slim]+source = "https://github.com/slimphp/Slim"+sha = "e12cb05ca2a14e8f459d019e87a31dc915b80470"+language = "php"+tier = 1++[roblox-lua-promise]+source = "https://github.com/evaera/roblox-lua-promise"+sha = "031d429c82ee458a849e79fa523523bd349d7695"+language = "luau"+tier = 2++[libuv]+source = "https://github.com/libuv/libuv"+sha = "cdc632c68feb3961f84ea109295db38dfa082347"+language = "c"+tier = 1++# Go repo WITH internal/ — exercises the Go internal/->Service layer hints+# that chi's flat layout never reaches.+[task]+source = "https://github.com/go-task/task"+sha = "f50327f2a2883f9e5b4d7c7c2ae489d6334e2bd9"+language = "go"+tier = 1++# --- Lightweight regex-resolver batch (promoted from passthrough) ---++[plug]+source = "https://github.com/elixir-plug/plug"+sha = "d2580b0579a7d804b2dfa0f9ed35d459236143ed"+language = "elixir"+tier = 2++[args]+source = "https://github.com/dart-lang/args"+sha = "7a2dfb528768f0a2e5680f711dbfb948f1d6c255"+language = "dart"+tier = 2++[compojure]+source = "https://github.com/weavejester/compojure"+sha = "8a4758d28e8fcd28fa7610dca6e2908d039e6a4f"+language = "clojure"+tier = 2++[aeson]+source = "https://github.com/haskell/aeson"+sha = "19f8eddb9bd6aaa464f21a54fa1f7cd7740112c3"+language = "haskell"+tier = 2++[argu]+source = "https://github.com/fsprojects/Argu"+sha = "198f4d50fd5208a84c4e02c87eba8cc92a13a5f0"+language = "fsharp"+tier = 2++# cowlib substitutes rebar3 (a large build tool with vendored deps) — a+# pure small Erlang library exercises include/behaviour/qualified-call+# resolution at harness-friendly size.+[cowlib]+source = "https://github.com/ninenines/cowlib"+sha = "71ae94fa42cbe55fdc5bfbb3d712ba8ab1b2918f"+language = "erlang"+tier = 2++# --- Structural-mode batch (no resolver; harness-only acceptance) ---++[zig-clap]+source = "https://github.com/Hejsil/zig-clap"+sha = "bf56f229ed5b6c381d90e192234913c6deb3f688"+language = "zig"+tier = 3++[jsony]+source = "https://github.com/treeform/jsony"+sha = "c5874fb71435e3ced8ee0025822e15f5d0e8e622"+language = "nim"+tier = 3++[dfmt]+source = "https://github.com/dlang-community/dfmt"+sha = "c65d1c8a9cd2d784ded4cc7517c2cdd42c0c5c76"+language = "dlang"+tier = 3++[glue]+source = "https://github.com/tidyverse/glue"+sha = "da9c73f7a3de6a27f3103cb5bb2355820a4c3a6a"+language = "r"+tier = 3++[ordered-collections]+source = "https://github.com/JuliaCollections/OrderedCollections.jl"+sha = "d5d76c771c7e5a49100ee65720a9d5a9654be420"+language = "julia"+tier = 3++[elm-html]+source = "https://github.com/elm/html"+sha = "1affbf39efef4b4529110a567f706130c178a457"+language = "elm"+tier = 3++[kemal]+source = "https://github.com/kemalcr/kemal"+sha = "73e4c01d0ae40a01feb3ca759eed709c356a6701"+language = "crystal"+tier = 3++[sexplib]+source = "https://github.com/janestreet/sexplib"+sha = "7d6edfaa89ae1182f51fe1161b86c773bdf31778"+language = "ocaml"+tier = 3++[afnetworking]+source = "https://github.com/AFNetworking/AFNetworking"+sha = "d9f589cc2c1fe9d55eb5eea00558010afea7a41e"+language = "objectivec"+tier = 3diff --git a/scripts/kg_validate/run.py b/scripts/kg_validate/run.pynew file mode 100644index 000000000..c478fe448--- /dev/null+++ b/scripts/kg_validate/run.py@@ -0,0 +1,216 @@+#!/usr/bin/env python3+"""KG validation harness — index the pinned matrix, check smells, diff baselines.++Usage (from the repo root):++ python scripts/kg_validate/run.py # check all matrix repos+ python scripts/kg_validate/run.py chi express # subset+ python scripts/kg_validate/run.py --skip-index # reuse existing exports+ python scripts/kg_validate/run.py --update-baselines+ python scripts/kg_validate/run.py --json # machine-readable+ python scripts/kg_validate/run.py --modules-report /tmp/modules.md++Environment:+ KG_VALIDATE_DIR clone/work dir (default /tmp/kg-validate)+ REPOWISE_PY python used to run the indexer (default: this python)++Each repo is cloned at its pinned SHA from matrix.toml, indexed with+REPOWISE_KG_CURATION=1, and its exported knowledge-graph.json is checked by+kg_checks. The previous run's ``.repowise/`` output is wiped before indexing+— indexing output must never contaminate the next run's input.++Baselines live next to this script in ``baselines/<repo>.json`` and are+committed; the density_regression smell diffs against them.+"""++from __future__ import annotations++import argparse+import json+import os+import shutil+import subprocess+import sys+import tomllib+from pathlib import Path++HERE = Path(__file__).resolve().parent+REPO_ROOT = HERE.parent.parent+BASELINE_DIR = HERE / "baselines"+WORK_DIR = Path(os.environ.get("KG_VALIDATE_DIR", "/tmp/kg-validate"))+PY = os.environ.get("REPOWISE_PY", sys.executable)+PYTHONPATH = os.pathsep.join(+ str(REPO_ROOT / p) for p in ("packages/core/src", "packages/cli/src", "packages/server/src")+)++sys.path.insert(0, str(HERE))+from kg_checks import RepoReport, compute_stats, run_smells # noqa: E402+++def load_matrix() -> dict[str, dict]:+ with open(HERE / "matrix.toml", "rb") as fh:+ return tomllib.load(fh)+++def import_support_map() -> dict[str, str]:+ sys.path.insert(0, str(REPO_ROOT / "packages/core/src"))+ from repowise.core.ingestion.languages.registry import REGISTRY++ return REGISTRY.import_support_map()+++def ensure_clone(name: str, spec: dict) -> Path:+ dest = WORK_DIR / name+ source = spec["source"]+ if not (dest / ".git").exists():+ WORK_DIR.mkdir(parents=True, exist_ok=True)+ if source.startswith(("http://", "https://", "git@")):+ src = source+ else:+ # Relative sources resolve against this script's dir first when+ # they name a committed bundle file (fixtures/*.bundle), else+ # against the repo root ("." = repowise itself). git clones+ # bundles like any other repo.+ local = HERE / source+ src = str(local if local.is_file() else REPO_ROOT / source)+ print(f" cloning {name} from {src} …")+ subprocess.run(["git", "clone", "--quiet", src, str(dest)], check=True)+ head = subprocess.run(+ ["git", "-C", str(dest), "rev-parse", "HEAD"], capture_output=True, text=True, check=True+ ).stdout.strip()+ if head != spec["sha"]:+ fetched = subprocess.run(+ ["git", "-C", str(dest), "checkout", "--quiet", spec["sha"]], capture_output=True+ )+ if fetched.returncode != 0:+ subprocess.run(["git", "-C", str(dest), "fetch", "--quiet", "origin", spec["sha"]],+ check=False)+ subprocess.run(["git", "-C", str(dest), "checkout", "--quiet", spec["sha"]], check=True)+ print(f" {name}: checked out pinned {spec['sha'][:10]}")+ return dest+++def index_repo(dest: Path) -> None:+ # Wipe previous output: indexing must never read its own prior artifacts.+ shutil.rmtree(dest / ".repowise", ignore_errors=True)+ env = {**os.environ, "REPOWISE_KG_CURATION": "1", "PYTHONPATH": PYTHONPATH}+ code = (+ "from repowise.cli.main import cli; "+ f"cli(['init', {str(dest)!r}, '--index-only', '--yes'])"+ )+ res = subprocess.run([PY, "-c", code], env=env, capture_output=True, text=True)+ if res.returncode != 0:+ raise RuntimeError(f"index failed for {dest.name}:\n{res.stdout[-2000:]}\n{res.stderr[-2000:]}")+++def check_repo(name: str, support: dict[str, str], *, skip_index: bool) -> RepoReport:+ matrix = load_matrix()+ spec = matrix[name]+ dest = ensure_clone(name, spec)+ if not skip_index:+ index_repo(dest)+ kg_path = dest / ".repowise" / "knowledge-graph.json"+ kg = json.loads(kg_path.read_text(encoding="utf-8"))++ stats = compute_stats(kg, support)+ baseline_path = BASELINE_DIR / f"{name}.json"+ baseline = (+ json.loads(baseline_path.read_text(encoding="utf-8")) if baseline_path.exists() else None+ )+ smells = run_smells(kg, stats, baseline)+ report = RepoReport(repo=name, stats=stats, smells=smells)+ # Keep tour paths in the report so baseline diffs show walk changes.+ report.stats["tour_paths"] = [s.get("target_path") for s in kg.get("tour", [])]+ report.stats["entry_points"] = (kg.get("project") or {}).get("entry_points", [])+ layer_names = {lyr.get("id"): lyr.get("name", "") for lyr in kg.get("layers", [])}+ report.modules_detail = [+ {+ "name": m.get("name", ""),+ "path": m.get("path", ""),+ "layer": layer_names.get(m.get("layerId"), m.get("layerId", "")),+ "size": len(m.get("nodeIds", [])),+ }+ for m in kg.get("modules", [])+ ]+ return report+++def main() -> int:+ ap = argparse.ArgumentParser()+ ap.add_argument("repos", nargs="*", help="subset of matrix repos")+ ap.add_argument("--skip-index", action="store_true")+ ap.add_argument("--update-baselines", action="store_true")+ ap.add_argument("--json", action="store_true", dest="as_json")+ ap.add_argument(+ "--modules-report",+ metavar="PATH",+ help="write a per-repo curated-module inventory (markdown) for human review",+ )+ args = ap.parse_args()++ matrix = load_matrix()+ names = args.repos or list(matrix)+ unknown = [n for n in names if n not in matrix]+ if unknown:+ ap.error(f"not in matrix.toml: {unknown}")++ support = import_support_map()+ reports: list[RepoReport] = []+ for name in names:+ print(f"== {name} ==")+ try:+ report = check_repo(name, support, skip_index=args.skip_index)+ except Exception as exc:+ report = RepoReport(repo=name, stats={}, smells=[])+ report.smells.append(type("S", (), {})()) # placeholder replaced below+ from kg_checks import Smell++ report.smells = [Smell("FAIL", "harness_error", str(exc)[:500])]+ reports.append(report)+ dom = report.stats.get("dominant_language")+ for lang, b in (report.stats.get("by_language") or {}).items():+ star = "*" if lang == dom else " "+ print(+ f" {star}{lang:<12} files={b['files']:<5} imports/file={b['edges_per_file']:<6}"+ f" resolution={b['resolution_rate']} orphans={b['orphan_ratio']:.0%}"+ f" [{b['import_support']}]"+ )+ for s in report.smells:+ print(f" !! {s.severity} {s.code}: {s.message}")+ if not report.smells:+ print(" OK — no smells")+ if args.update_baselines and not any(+ s.code == "harness_error" for s in report.smells+ ):+ BASELINE_DIR.mkdir(exist_ok=True)+ (BASELINE_DIR / f"{name}.json").write_text(+ json.dumps(report.as_dict(), indent=1, sort_keys=True) + "\n", encoding="utf-8"+ )+ print(" baseline updated")++ if args.as_json:+ print(json.dumps([r.as_dict() for r in reports], indent=1, sort_keys=True))++ if args.modules_report:+ lines = ["# Curated module inventory", ""]+ for r in reports:+ lines.append(f"## {r.repo}")+ if not r.modules_detail:+ lines.extend(["", "_no modules in artifact_", ""])+ continue+ lines.extend(["", "| Module | Path | Layer | Files |", "|---|---|---|---|"])+ for m in sorted(r.modules_detail, key=lambda m: (-m["size"], m["name"])):+ lines.append(+ f"| {m['name']} | `{m['path'] or '(layer root)'}` | {m['layer']} | {m['size']} |"+ )+ lines.append("")+ Path(args.modules_report).write_text("\n".join(lines) + "\n", encoding="utf-8")+ print(f"modules report written to {args.modules_report}")++ failed = [r.repo for r in reports if r.failed]+ print(f"\n{len(reports) - len(failed)}/{len(reports)} clean" + (f"; FAILED: {failed}" if failed else ""))+ return 1 if failed else 0+++if __name__ == "__main__":+ raise SystemExit(main())diff --git a/tests/unit/tools/test_kg_validate_checks.py b/tests/unit/tools/test_kg_validate_checks.pynew file mode 100644index 000000000..5abd30fa4--- /dev/null+++ b/tests/unit/tools/test_kg_validate_checks.py@@ -0,0 +1,466 @@+"""Unit tests for the KG validation harness checks (scripts/kg_validate)."""++from __future__ import annotations++import sys+from pathlib import Path++REPO_ROOT = Path(__file__).resolve().parents[3]+sys.path.insert(0, str(REPO_ROOT / "scripts" / "kg_validate"))++from kg_checks import Smell, compute_stats, run_smells # noqa: E402+++def _kg(+ *,+ files: list[tuple[str, str]], # (path, language)+ imports: list[tuple[str, str]] = (), # (src_path, dst_path-or-external:..)+ layers: list[dict] | None = None,+ tour: list[dict] | None = None,+ entry_points: list[str] | None = None,+) -> dict:+ nodes = [+ {"id": f"file:{p}", "type": "file", "filePath": p, "language": lang}+ for p, lang in files+ ]+ edges = [+ {+ "source": f"file:{s}",+ "target": f"file:{d}",+ "type": "imports",+ "direction": "forward",+ "weight": 1.0,+ }+ for s, d in imports+ ]+ return {+ "version": "1.0.0",+ "project": {+ "name": "x",+ "total_files": len(files),+ "entry_points": entry_points or [],+ },+ "nodes": nodes,+ "edges": edges,+ "layers": layers or [],+ "tour": tour or [],+ }+++SUPPORT = {"go": "full", "python": "full", "elixir": "none"}+++class TestComputeStats:+ def test_density_and_resolution(self) -> None:+ kg = _kg(+ files=[("a.go", "go"), ("b.go", "go"), ("c.go", "go")],+ imports=[("a.go", "b.go"), ("a.go", "external:net/http")],+ )+ stats = compute_stats(kg, SUPPORT)+ go = stats["by_language"]["go"]+ assert go["files"] == 3+ assert go["import_edges"] == 2+ assert go["edges_per_file"] == 0.67+ assert go["resolution_rate"] == 0.5+ assert go["import_support"] == "full"++ def test_orphans_count_unconnected_files(self) -> None:+ kg = _kg(+ files=[("a.go", "go"), ("b.go", "go"), ("c.go", "go")],+ imports=[("a.go", "b.go")],+ )+ go = compute_stats(kg, SUPPORT)["by_language"]["go"]+ assert go["orphan_files"] == 1 # c.go has no edges either way+ assert go["orphan_ratio"] == 0.333++ def test_dominant_language(self) -> None:+ kg = _kg(files=[("a.py", "python"), ("b.py", "python"), ("c.go", "go")])+ assert compute_stats(kg, SUPPORT)["dominant_language"] == "python"+++class TestSmells:+ def _clean_tour(self) -> list[dict]:+ return [+ {"order": i + 1, "target_path": f"f{i}.py", "kind": "code", "reason": "x"}+ for i in range(7)+ ]++ def test_clean_kg_has_no_smells(self) -> None:+ kg = _kg(+ files=[("f0.py", "python"), ("f1.py", "python")],+ imports=[("f0.py", "f1.py")],+ tour=self._clean_tour(),+ )+ smells = run_smells(kg, compute_stats(kg, SUPPORT))+ assert smells == []++ def test_test_layer_not_last(self) -> None:+ layers = [+ {"id": "layer:test", "name": "Test", "nodeIds": [], "display_order": 0},+ {"id": "layer:app", "name": "Application", "nodeIds": [], "display_order": 1},+ ]+ kg = _kg(files=[("a.py", "python")], layers=layers, tour=self._clean_tour())+ codes = {s.code for s in run_smells(kg, compute_stats(kg, SUPPORT))}+ assert "test_layer_not_last" in codes++ def test_test_file_early_in_tour(self) -> None:+ tour = self._clean_tour()+ tour[1]["target_path"] = "tests/conftest.py"+ kg = _kg(files=[("a.py", "python")], tour=tour)+ codes = {s.code for s in run_smells(kg, compute_stats(kg, SUPPORT))}+ assert "test_file_early_in_tour" in codes++ def test_duplicate_and_example_and_dotdir(self) -> None:+ tour = self._clean_tour()+ tour[2]["target_path"] = "f1.py" # dup of step 2+ tour[3]["target_path"] = "examples/demo.py"+ tour[4]["target_path"] = ".github/x.py"+ kg = _kg(files=[("a.py", "python")], tour=tour)+ codes = {s.code for s in run_smells(kg, compute_stats(kg, SUPPORT))}+ assert {"duplicate_tour_targets", "example_file_in_tour", "dot_dir_file_in_tour"} <= codes++ def test_tour_too_short_is_warn(self) -> None:+ kg = _kg(files=[("a.py", "python")], tour=self._clean_tour()[:3])+ smells = run_smells(kg, compute_stats(kg, SUPPORT))+ short = [s for s in smells if s.code == "tour_too_short"]+ assert short and short[0].severity == "WARN"++ def test_edgeless_graph_fails_for_full_support(self) -> None:+ kg = _kg(files=[(f"f{i}.go", "go") for i in range(10)], tour=self._clean_tour())+ codes = {s.code for s in run_smells(kg, compute_stats(kg, SUPPORT))}+ assert "edgeless_graph" in codes++ def test_edgeless_graph_ok_for_none_support(self) -> None:+ kg = _kg(+ files=[(f"f{i}.ex", "elixir") for i in range(10)], tour=self._clean_tour()+ )+ codes = {s.code for s in run_smells(kg, compute_stats(kg, SUPPORT))}+ assert "edgeless_graph" not in codes++ def test_tier_gates_exempt_small_repos(self) -> None:+ # 2 files, no imports between them: edgeless/floor/ceiling must all+ # stay quiet — a tiny repo without internal imports is normal.+ kg = _kg(files=[("a.go", "go"), ("b.go", "go")], tour=self._clean_tour())+ codes = {s.code for s in run_smells(kg, compute_stats(kg, SUPPORT))}+ assert not codes & {"edgeless_graph", "density_floor", "orphan_ceiling"}++ def test_density_regression_against_baseline(self) -> None:+ kg = _kg(+ files=[("a.go", "go"), ("b.go", "go")],+ imports=[("a.go", "b.go")],+ tour=self._clean_tour(),+ )+ stats = compute_stats(kg, SUPPORT)+ baseline = {"stats": {"by_language": {"go": {"edges_per_file": 5.0}}}}+ smells = run_smells(kg, stats, baseline)+ assert any(s.code == "density_regression" and s.severity == "FAIL" for s in smells)++ def test_no_regression_within_tolerance(self) -> None:+ kg = _kg(+ files=[("a.go", "go")],+ imports=[("a.go", "b.go")],+ tour=self._clean_tour(),+ )+ stats = compute_stats(kg, SUPPORT)+ baseline = {"stats": {"by_language": {"go": {"edges_per_file": 1.1}}}}+ assert not any(+ s.code == "density_regression" for s in run_smells(kg, stats, baseline)+ )++ def test_catchall_layer_warns(self) -> None:+ layers = [+ {"id": "layer:app", "name": "Application", "display_order": 0,+ "nodeIds": [f"file:f{i}.py" for i in range(9)]},+ {"id": "layer:test", "name": "Test", "display_order": 1,+ "nodeIds": ["file:t.py"]},+ ]+ kg = _kg(+ files=[(f"f{i}.py", "python") for i in range(9)] + [("t.py", "python")],+ imports=[("f0.py", "f1.py")],+ layers=layers,+ tour=self._clean_tour(),+ )+ smells = run_smells(kg, compute_stats(kg, SUPPORT))+ catchall = [s for s in smells if s.code == "catchall_layer"]+ assert catchall and catchall[0].severity == "WARN"++ def test_density_floor_fails_below_tier_floor(self) -> None:+ # 12 go files (full tier, above the small-repo cutoff), one edge:+ # 0.08 e/f clears EDGELESS_FLOOR but not the full-tier floor of 0.9.+ kg = _kg(+ files=[(f"f{i}.go", "go") for i in range(12)],+ imports=[("f0.go", "f1.go")],+ tour=self._clean_tour(),+ )+ smells = run_smells(kg, compute_stats(kg, SUPPORT))+ floor = [s for s in smells if s.code == "density_floor"]+ assert floor and floor[0].severity == "FAIL"++ def test_orphan_ceiling_fails_above_tier_ceiling(self) -> None:+ # 10 files, 4 orphans = 0.4 > the full-tier ceiling of 0.30.+ kg = _kg(+ files=[(f"f{i}.go", "go") for i in range(10)],+ imports=[(f"f{i}.go", f"f{i + 1}.go") for i in range(5)]+ + [(f"f{i}.go", f"f{i}.go") for i in (0,) * 15], # keep density above floor+ tour=self._clean_tour(),+ )+ stats = compute_stats(kg, SUPPORT)+ assert stats["by_language"]["go"]["orphan_ratio"] > 0.30+ smells = run_smells(kg, stats)+ ceiling = [s for s in smells if s.code == "orphan_ceiling"]+ assert ceiling and ceiling[0].severity == "FAIL"++ def test_catchall_layer_fails_above_95_when_big_enough(self) -> None:+ n = 40+ layers = [+ {"id": "layer:app", "name": "Application", "display_order": 0,+ "nodeIds": [f"file:f{i}.py" for i in range(n - 1)]},+ {"id": "layer:test", "name": "Test", "display_order": 1,+ "nodeIds": ["file:t.py"]},+ ]+ kg = _kg(+ files=[(f"f{i}.py", "python") for i in range(n - 1)] + [("t.py", "python")],+ imports=[(f"f{i}.py", f"f{i + 1}.py") for i in range(n - 2)],+ layers=layers,+ tour=self._clean_tour(),+ )+ smells = run_smells(kg, compute_stats(kg, SUPPORT))+ catchall = [s for s in smells if s.code == "catchall_layer"]+ assert catchall and catchall[0].severity == "FAIL"++ def test_catchall_layer_stays_warn_below_size_gate(self) -> None:+ # 96% catch-all but only 10 code files — tiny flat repos are honest.+ layers = [+ {"id": "layer:app", "name": "Application", "display_order": 0,+ "nodeIds": [f"file:f{i}.py" for i in range(24)]},+ {"id": "layer:test", "name": "Test", "display_order": 1,+ "nodeIds": ["file:t.py"]},+ ]+ kg = _kg(+ files=[(f"f{i}.py", "python") for i in range(9)] + [("t.py", "python")],+ imports=[(f"f{i}.py", f"f{i + 1}.py") for i in range(8)],+ layers=layers,+ tour=self._clean_tour(),+ )+ smells = run_smells(kg, compute_stats(kg, SUPPORT))+ catchall = [s for s in smells if s.code == "catchall_layer"]+ assert catchall and catchall[0].severity == "WARN"++ def test_entry_point_sanity(self) -> None:+ kg = _kg(+ files=[("a.py", "python")],+ imports=[("a.py", "b.py")],+ tour=self._clean_tour(),+ entry_points=["missing.py", "tests/test_x.py"],+ )+ codes = {s.code for s in run_smells(kg, compute_stats(kg, SUPPORT))}+ assert {"entry_point_missing", "entry_point_is_test"} <= codes++ def test_entry_claim_without_entry_points(self) -> None:+ tour = self._clean_tour()+ tour[0]["reason"] = "An entry point — execution and imports fan out from here."+ kg = _kg(files=[("f0.py", "python")], imports=[("f0.py", "f1.py")], tour=tour)+ codes = {s.code for s in run_smells(kg, compute_stats(kg, SUPPORT))}+ assert "entry_claim_without_entry_points" in codes++ def test_smell_dataclass_shape(self) -> None:+ s = Smell("WARN", "x", "y")+ assert (s.severity, s.code, s.message) == ("WARN", "x", "y")+++class TestModuleSmells:+ """Curated wiki module invariants (kg.modules)."""++ def _clean_tour(self) -> list[dict]:+ return [+ {"order": i + 1, "target_path": f"src/app/f{i}.py", "kind": "code", "reason": "x"}+ for i in range(7)+ ]++ def _kg_with_modules(self, n_app: int = 12, n_test: int = 0, modules=None) -> dict:+ app_files = [(f"src/app/f{i}.py", "python") for i in range(n_app)]+ test_files = [(f"tests/t{i}.py", "python") for i in range(n_test)]+ layers = [+ {"id": "layer:app", "name": "Application", "display_order": 0,+ "nodeIds": [f"file:{p}" for p, _ in app_files]},+ ]+ if test_files:+ layers.append(+ {"id": "layer:test", "name": "Test", "display_order": 1,+ "nodeIds": [f"file:{p}" for p, _ in test_files]}+ )+ kg = _kg(+ files=app_files + test_files,+ imports=[(f"src/app/f{i}.py", f"src/app/f{i + 1}.py") for i in range(n_app - 1)],+ layers=layers,+ tour=self._clean_tour(),+ )+ if modules is not None:+ kg["modules"] = modules+ return kg++ def _module(self, name: str, path: str, node_ids: list[str], layer_id: str = "layer:app") -> dict:+ return {+ "id": f"module:{name.replace('/', '-')}",+ "name": name,+ "path": path,+ "layerId": layer_id,+ "nodeIds": node_ids,+ }++ def _codes(self, kg: dict) -> set[str]:+ return {s.code for s in run_smells(kg, compute_stats(kg, SUPPORT))}++ def test_clean_modules_have_no_module_smells(self) -> None:+ app = [(f"src/app/f{i}.py", "python") for i in range(6)]+ web = [(f"src/web/w{i}.py", "python") for i in range(6)]+ layers = [+ {"id": "layer:app", "name": "Application", "display_order": 0,+ "nodeIds": [f"file:{p}" for p, _ in app + web]},+ ]+ kg = _kg(files=app + web, imports=[], layers=layers, tour=self._clean_tour())+ kg["modules"] = [+ self._module("app", "src/app", [f"file:{p}" for p, _ in app]),+ self._module("web", "src/web", [f"file:{p}" for p, _ in web]),+ ]+ assert not any(c.startswith("module") for c in self._codes(kg))++ def test_partition_violation_fails(self) -> None:+ kg = self._kg_with_modules()+ ids = [f"file:src/app/f{i}.py" for i in range(12)]+ kg["modules"] = [+ self._module("app", "src/app", ids),+ self._module("dupe", "src/app2", ids[:1]),+ ]+ assert "module_partition" in self._codes(kg)++ def test_coverage_gap_fails(self) -> None:+ kg = self._kg_with_modules()+ kg["modules"] = [+ self._module("app", "src/app", [f"file:src/app/f{i}.py" for i in range(6)])+ ]+ assert "module_coverage" in self._codes(kg)++ def test_name_collision_and_size_suffix_fail(self) -> None:+ kg = self._kg_with_modules()+ ids = [f"file:src/app/f{i}.py" for i in range(12)]+ kg["modules"] = [+ self._module("app (6)", "src/app", ids[:6]),+ {**self._module("app (6)", "src/app2", ids[6:]), "id": "module:app-2"},+ ]+ codes = self._codes(kg)+ assert {"module_name_collision", "module_size_suffix"} <= codes++ def test_generic_only_name_fails(self) -> None:+ # "src" appears in 100% of paths → namespace noise; the module's own+ # path offered an informative segment ("app", 50% of paths), so a+ # generic-only name is a derivation bug, not a forced fallback.+ app = [(f"src/app/f{i}.py", "python") for i in range(6)]+ web = [(f"src/web/w{i}.py", "python") for i in range(6)]+ layers = [+ {"id": "layer:app", "name": "Application", "display_order": 0,+ "nodeIds": [f"file:{p}" for p, _ in app + web]},+ ]+ kg = _kg(files=app + web, imports=[], layers=layers, tour=self._clean_tour())+ kg["modules"] = [+ self._module("src", "src/app", [f"file:{p}" for p, _ in app]),+ self._module("web", "src/web", [f"file:{p}" for p, _ in web]),+ ]+ assert "module_generic_name" in self._codes(kg)++ def test_generic_name_exempt_when_no_alternative_exists(self) -> None:+ # Fixture-dominated repos (aeson-shaped): every segment of the module+ # path is dominant — the raw tail is the best name available and+ # flagging it would demand a name that cannot exist.+ files = [(f"suite/case{i}.json", "python") for i in range(10)]+ layers = [+ {"id": "layer:test", "name": "Test", "display_order": 0,+ "nodeIds": [f"file:{p}" for p, _ in files]},+ ]+ kg = _kg(files=files, imports=[], layers=layers, tour=self._clean_tour())+ kg["modules"] = [+ self._module("suite", "suite", [f"file:{p}" for p, _ in files],+ layer_id="layer:test")+ ]+ assert "module_generic_name" not in self._codes(kg)++ def test_layer_named_module_is_exempt_from_generic_check(self) -> None:+ # Whole-layer fallback names a module after its layer; honest even if+ # the lowercased layer name is also a dominant path segment.+ kg = self._kg_with_modules()+ kg["nodes"] = [+ {"id": f"file:application/f{i}.py", "type": "file",+ "filePath": f"application/f{i}.py", "language": "python"}+ for i in range(12)+ ]+ kg["layers"] = [+ {"id": "layer:app", "name": "Application", "display_order": 0,+ "nodeIds": [f"file:application/f{i}.py" for i in range(12)]}+ ]+ kg["modules"] = [+ self._module(+ "Application", "", [f"file:application/f{i}.py" for i in range(12)]+ )+ ]+ codes = self._codes(kg)+ assert "module_generic_name" not in codes++ def test_oversized_with_subdirs_warns_flat_does_not(self) -> None:+ n = 130+ deep_files = [(f"src/app/sub{i % 4}/f{i}.py", "python") for i in range(n)]+ layers = [+ {"id": "layer:app", "name": "Application", "display_order": 0,+ "nodeIds": [f"file:{p}" for p, _ in deep_files]},+ ]+ kg = _kg(files=deep_files, imports=[], layers=layers, tour=self._clean_tour())+ kg["modules"] = [+ self._module("app", "src/app", [f"file:{p}" for p, _ in deep_files])+ ]+ assert "module_oversized" in self._codes(kg)++ flat_files = [(f"src/app/f{i}.py", "python") for i in range(n)]+ layers[0]["nodeIds"] = [f"file:{p}" for p, _ in flat_files]+ kg2 = _kg(files=flat_files, imports=[], layers=layers, tour=self._clean_tour())+ kg2["modules"] = [+ self._module("app", "src/app", [f"file:{p}" for p, _ in flat_files])+ ]+ assert "module_oversized" not in self._codes(kg2)++ def test_confetti_module_count_warns(self) -> None:+ kg = self._kg_with_modules(n_app=32)+ kg["modules"] = [+ self._module(f"m{i}", f"src/app/m{i}", [f"file:src/app/f{i}.py"])+ for i in range(32)+ ]+ assert "module_count" in self._codes(kg)++ def test_module_count_exempts_small_repos(self) -> None:+ # 12 files / 2 modules trips files//8 arithmetically but is honest+ # structure, not confetti — small repos are exempt from the gate.+ kg = self._kg_with_modules(n_app=12)+ kg["modules"] = [+ self._module("a", "src/app/a", [f"file:src/app/f{i}.py" for i in range(6)]),+ self._module("b", "src/app/b", [f"file:src/app/f{i}.py" for i in range(6, 12)]),+ ]+ assert "module_count" not in self._codes(kg)++ def test_test_layer_without_modules_warns(self) -> None:+ kg = self._kg_with_modules(n_app=12, n_test=35)+ kg["modules"] = [+ self._module("app", "src/app", [f"file:src/app/f{i}.py" for i in range(12)])+ ]+ # Test layer (35 files) fully uncovered → coverage FAIL fires too;+ # the dedicated WARN names the user-valued invariant explicitly.+ assert "test_modules_missing" in self._codes(kg)++ def test_modules_missing_warns_on_big_curated_repo(self) -> None:+ kg = self._kg_with_modules(n_app=35)+ assert "modules_missing" in self._codes(kg)++ def test_modules_snapshot_in_stats(self) -> None:+ kg = self._kg_with_modules()+ kg["modules"] = [+ self._module("app", "src/app", [f"file:src/app/f{i}.py" for i in range(12)])+ ]+ snap = compute_stats(kg, SUPPORT)["modules"]+ assert snap == {"count": 1, "names": ["app"], "min_size": 12, "max_size": 12}