Skip to content

Codebase intelligence for AI and humans: code health scores, auto-generated docs, git analytics, dead code detection, and architectural decisions via MCP.

refactor(core): move the lead fold into core, add heritage kinds, compare change health without a checkout (#2494)

Raghav Chamadiyaeb151881bb8a
diff --git a/.github/workflows/publish-internal.yml b/.github/workflows/publish-internal.yml
index 4f9496265..050b1617b 100644
--- a/.github/workflows/publish-internal.yml
+++ b/.github/workflows/publish-internal.yml
@@ -111,7 +111,7 @@ jobs:
run: |
npm pkg set version="$VERSION"
npm pkg set dependencies.@repowise-dev/types="$VERSION"
- # ``./c4``, ``./graph`` and ``./hosted`` import types from ui, and the
+ # ``./c4`` and ``./graph`` import types from ui, and the
# package ships raw TypeScript, so a consumer compiling it needs ui
# resolvable. It is a devDependency here because this repo builds
# against the workspace copy.
diff --git a/packages/api-client/package.json b/packages/api-client/package.json
index da6e5a6d4..e377e1c94 100644
--- a/packages/api-client/package.json
+++ b/packages/api-client/package.json
@@ -28,7 +28,6 @@
"./git": "./src/git.ts",
"./graph": "./src/graph.ts",
"./health": "./src/health.ts",
- "./hosted": "./src/hosted.ts",
"./jobs": "./src/jobs.ts",
"./knowledge-map": "./src/knowledge-map.ts",
"./mcp-tools": "./src/mcp-tools.ts",
diff --git a/packages/api-client/src/__fixtures__/hosted/architecture-view.json b/packages/api-client/src/__fixtures__/hosted/architecture-view.json
deleted file mode 100644
index a03a6ec1c..000000000
--- a/packages/api-client/src/__fixtures__/hosted/architecture-view.json
+++ /dev/null
@@ -1,496 +0,0 @@
-{
- "project_name": "flask",
- "project_description": "",
- "layers": [
- {
- "id": "layer:application",
- "name": "Application",
- "description": "",
- "node_ids": [
- ".pre-commit-config.yaml",
- ".readthedocs.yaml",
- "README.md",
- "pyproject.toml",
- "src/flask/__init__.py",
- "src/flask/__main__.py",
- "src/flask/cli.py",
- "src/flask/globals.py",
- "src/flask/helpers.py",
- "src/flask/debughelpers.py",
- "src/flask/signals.py",
- "src/flask/app.py",
- "src/flask/testing.py",
- "src/flask/typing.py",
- "src/flask/views.py",
- "src/flask/wrappers.py",
- "src/flask/sessions.py",
- "src/flask/json/__init__.py",
- "src/flask/sansio/README.md",
- "src/flask/config.py",
- "src/flask/sansio/app.py",
- "src/flask/json/tag.py",
- "src/flask/ctx.py",
- "src/flask/logging.py",
- "src/flask/templating.py",
- "src/flask/sansio/scaffold.py",
- "src/flask/json/provider.py",
- "src/flask/blueprints.py",
- "src/flask/sansio/blueprints.py"
- ],
- "file_count": 29,
- "complexity_distribution": {
- "simple": 7,
- "moderate": 8,
- "complex": 14
- },
- "health_score": null,
- "sub_groups": [],
- "display_order": 0
- },
- {
- "id": "layer:config",
- "name": "Config",
- "description": "",
- "node_ids": [
- ".devcontainer/on-create-command.sh",
- ".github/pull_request_template.md",
- ".github/ISSUE_TEMPLATE/bug-report.md",
- ".github/ISSUE_TEMPLATE/config.yml",
- ".github/ISSUE_TEMPLATE/feature-request.md",
- ".github/workflows/lock.yaml",
- ".devcontainer/devcontainer.json",
- ".github/workflows/pre-commit.yaml",
- ".github/workflows/publish.yaml",
- ".github/workflows/tests.yaml",
- ".github/workflows/zizmor.yaml"
- ],
- "file_count": 11,
- "complexity_distribution": {
- "simple": 11,
- "moderate": 0,
- "complex": 0
- },
- "health_score": null,
- "sub_groups": [],
- "display_order": 1
- },
- {
- "id": "layer:docs-tooling",
- "name": "Docs & Tooling",
- "description": "",
- "node_ids": [
- "docs/Makefile",
- "docs/conf.py",
- "examples/celery/README.md",
- "examples/celery/pyproject.toml",
- "examples/celery/src/task_app/__init__.py",
- "examples/celery/src/task_app/views.py",
- "examples/celery/src/task_app/tasks.py",
- "examples/celery/make_celery.py",
- "examples/javascript/pyproject.toml",
- "examples/javascript/js_example/views.py",
- "examples/javascript/js_example/__init__.py",
- "examples/tutorial/pyproject.toml",
- "examples/tutorial/flaskr/auth.py",
- "examples/tutorial/flaskr/db.py",
- "examples/tutorial/flaskr/schema.sql",
- "examples/tutorial/flaskr/blog.py",
- "examples/tutorial/flaskr/__init__.py"
- ],
- "file_count": 17,
- "complexity_distribution": {
- "simple": 12,
- "moderate": 4,
- "complex": 1
- },
- "health_score": null,
- "sub_groups": [],
- "display_order": 2
- }
- ],
- "nodes": [
- {
- "id": ".devcontainer/devcontainer.json",
- "node_type": "config",
- "name": "devcontainer.json",
- "file_path": ".devcontainer/devcontainer.json",
- "line_range": null,
- "summary": "Configuration file: devcontainer.json.",
- "complexity": "simple",
- "tags": [
- "config"
- ],
- "language": "json",
- "pagerank": 0.0021357579334815545,
- "pagerank_percentile": 0,
- "betweenness": 0,
- "in_degree": 0,
- "out_degree": 1,
- "community_id": 4,
- "is_entry_point": false,
- "is_test": false,
- "is_hotspot": false,
- "is_dead": false,
- "has_doc": false,
- "primary_owner": null,
- "primary_owner_pct": null,
- "bus_factor": null
- },
- {
- "id": ".devcontainer/on-create-command.sh",
- "node_type": "file",
- "name": "on-create-command.sh",
- "file_path": ".devcontainer/on-create-command.sh",
- "line_range": null,
- "summary": "Config module on-create-command.",
- "complexity": "simple",
- "tags": [
- "shell",
- ".devcontainer"
- ],
- "language": "shell",
- "pagerank": 0.0021357579334815545,
- "pagerank_percentile": 0,
- "betweenness": 0,
- "in_degree": 0,
- "out_degree": 1,
- "community_id": 5,
- "is_entry_point": false,
- "is_test": false,
- "is_hotspot": false,
- "is_dead": false,
- "has_doc": false,
- "primary_owner": "emisargent",
- "primary_owner_pct": 0.8571428571428571,
- "bus_factor": 2
- },
- {
- "id": ".github/ISSUE_TEMPLATE/bug-report.md",
- "node_type": "document",
- "name": "bug-report.md",
- "file_path": ".github/ISSUE_TEMPLATE/bug-report.md",
- "line_range": null,
- "summary": "Documentation: bug-report.md.",
- "complexity": "simple",
- "tags": [
- "markdown",
- "ISSUE_TEMPLATE"
- ],
- "language": "markdown",
- "pagerank": 0.0021357579334815545,
- "pagerank_percentile": 0,
- "betweenness": 0,
- "in_degree": 0,
- "out_degree": 1,
- "community_id": 6,
- "is_entry_point": false,
- "is_test": false,
- "is_hotspot": false,
- "is_dead": false,
- "has_doc": false,
- "primary_owner": null,
- "primary_owner_pct": null,
- "bus_factor": null
- }
- ],
- "edges": [
- {
- "source": "examples/celery/make_celery.py",
- "target": "examples/celery/src/task_app/__init__.py",
- "edge_type": "imports",
- "direction": "forward",
- "weight": 1,
- "confidence": 1
- },
- {
- "source": "examples/celery/src/task_app/__init__.py",
- "target": "examples/celery/src/task_app/views.py",
- "edge_type": "imports",
- "direction": "forward",
- "weight": 1,
- "confidence": 1
- },
- {
- "source": "examples/celery/src/task_app/__init__.py",
- "target": "src/flask/__init__.py",
- "edge_type": "imports",
- "direction": "forward",
- "weight": 1,
- "confidence": 1
- }
- ],
- "tour": [
- {
- "order": 1,
- "title": "README.md",
- "description": "",
- "node_ids": [
- "README.md"
- ],
- "target_path": "README.md",
- "layer_id": "layer:application",
- "reason": "Start here for the end-to-end picture before diving into the code.",
- "depth": 0,
- "kind": "overview",
- "page_type": "repo_overview"
- },
- {
- "order": 2,
- "title": "app.py",
- "description": "",
- "node_ids": [
- "src/flask/app.py"
- ],
- "target_path": "src/flask/app.py",
- "layer_id": "layer:application",
- "reason": "An entry point — execution and imports fan out from here.",
- "depth": 0,
- "kind": "code",
- "page_type": "file_page"
- }
- ],
- "total_files": 108,
- "total_symbols": 1060,
- "total_edges": 257,
- "languages": [
- "json",
- "makefile",
- "markdown",
- "python",
- "shell",
- "sql",
- "toml",
- "yaml"
- ],
- "frameworks": [
- "flask"
- ],
- "external_systems": [
- {
- "id": "ext:amqp",
- "name": "amqp",
- "display_name": "Amqp",
- "category": "library",
- "ecosystem": "pypi",
- "version": "==5.1.1",
- "io_kind": null
- },
- {
- "id": "ext:asgiref",
- "name": "asgiref",
- "display_name": "Asgiref",
- "category": "library",
- "ecosystem": "pypi",
- "version": ">=3.2",
- "io_kind": null
- },
- {
- "id": "ext:async-timeout",
- "name": "async-timeout",
- "display_name": "Async Timeout",
- "category": "library",
- "ecosystem": "pypi",
- "version": "==4.0.2",
- "io_kind": null
- },
- {
- "id": "ext:billiard",
- "name": "billiard",
- "display_name": "Billiard",
- "category": "library",
- "ecosystem": "pypi",
- "version": "==3.6.4.0",
- "io_kind": null
- },
- {
- "id": "ext:blinker",
- "name": "blinker",
- "display_name": "Blinker",
- "category": "library",
- "ecosystem": "pypi",
- "version": ">=1.9.0",
- "io_kind": null
- },
- {
- "id": "ext:celery",
- "name": "celery",
- "display_name": "Celery",
- "category": "library",
- "ecosystem": "pypi",
- "version": null,
- "io_kind": null
- },
- {
- "id": "ext:click",
- "name": "click",
- "display_name": "Click",
- "category": "library",
- "ecosystem": "pypi",
- "version": ">=8.1.3",
- "io_kind": null
- },
- {
- "id": "ext:click-didyoumean",
- "name": "click-didyoumean",
- "display_name": "Click Didyoumean",
- "category": "library",
- "ecosystem": "pypi",
- "version": "==0.3.0",
- "io_kind": null
- },
- {
- "id": "ext:click-plugins",
- "name": "click-plugins",
- "display_name": "Click Plugins",
- "category": "library",
- "ecosystem": "pypi",
- "version": "==1.1.1",
- "io_kind": null
- },
- {
- "id": "ext:click-repl",
- "name": "click-repl",
- "display_name": "Click Repl",
- "category": "library",
- "ecosystem": "pypi",
- "version": "==0.2.0",
- "io_kind": null
- },
- {
- "id": "ext:flask",
- "name": "flask",
- "display_name": "Flask",
- "category": "framework",
- "ecosystem": "pypi",
- "version": null,
- "io_kind": null
- },
- {
- "id": "ext:itsdangerous",
- "name": "itsdangerous",
- "display_name": "Itsdangerous",
- "category": "library",
- "ecosystem": "pypi",
- "version": ">=2.2.0",
- "io_kind": null
- },
- {
- "id": "ext:jinja2",
- "name": "jinja2",
- "display_name": "Jinja2",
- "category": "library",
- "ecosystem": "pypi",
- "version": ">=3.1.2",
- "io_kind": null
- },
- {
- "id": "ext:kombu",
- "name": "kombu",
- "display_name": "Kombu",
- "category": "library",
- "ecosystem": "pypi",
- "version": "==5.2.4",
- "io_kind": null
- },
- {
- "id": "ext:markupsafe",
- "name": "markupsafe",
- "display_name": "Markupsafe",
- "category": "library",
- "ecosystem": "pypi",
- "version": ">=2.1.1",
- "io_kind": null
- },
- {
- "id": "ext:prompt-toolkit",
- "name": "prompt-toolkit",
- "display_name": "Prompt Toolkit",
- "category": "library",
- "ecosystem": "pypi",
- "version": "==3.0.38",
- "io_kind": null
- },
- {
- "id": "ext:pytest",
- "name": "pytest",
- "display_name": "Pytest",
- "category": "tool",
- "ecosystem": "pypi",
- "version": null,
- "io_kind": null
- },
- {
- "id": "ext:python-dotenv",
- "name": "python-dotenv",
- "display_name": "Python Dotenv",
- "category": "library",
- "ecosystem": "pypi",
- "version": null,
- "io_kind": null
- },
- {
- "id": "ext:pytz",
- "name": "pytz",
- "display_name": "Pytz",
- "category": "library",
- "ecosystem": "pypi",
- "version": "==2023.3",
- "io_kind": null
- },
- {
- "id": "ext:redis",
- "name": "redis",
- "display_name": "Redis",
- "category": "service",
- "ecosystem": "pypi",
- "version": "==4.5.4",
- "io_kind": "db"
- },
- {
- "id": "ext:six",
- "name": "six",
- "display_name": "Six",
- "category": "library",
- "ecosystem": "pypi",
- "version": "==1.16.0",
- "io_kind": null
- },
- {
- "id": "ext:vine",
- "name": "vine",
- "display_name": "Vine",
- "category": "library",
- "ecosystem": "pypi",
- "version": "==5.0.0",
- "io_kind": null
- },
- {
- "id": "ext:wcwidth",
- "name": "wcwidth",
- "display_name": "Wcwidth",
- "category": "library",
- "ecosystem": "pypi",
- "version": "==0.2.6",
- "io_kind": null
- },
- {
- "id": "ext:werkzeug",
- "name": "werkzeug",
- "display_name": "Werkzeug",
- "category": "library",
- "ecosystem": "pypi",
- "version": ">=3.1.0",
- "io_kind": null
- }
- ],
- "entry_points": [
- "src/flask/app.py",
- "src/flask/__main__.py",
- "src/flask/sansio/app.py"
- ],
- "entry_candidates": [
- "src/flask/app.py",
- "src/flask/__main__.py",
- "src/flask/sansio/app.py"
- ]
-}
diff --git a/packages/api-client/src/__fixtures__/hosted/architecture.json b/packages/api-client/src/__fixtures__/hosted/architecture.json
deleted file mode 100644
index 5e4526a18..000000000
--- a/packages/api-client/src/__fixtures__/hosted/architecture.json
+++ /dev/null
@@ -1,116 +0,0 @@
-{
- "nodes": [
- {
- "community_id": 0,
- "label": "tests",
- "cohesion": 0.066,
- "member_count": 53,
- "top_file": "src/flask/__init__.py",
- "avg_pagerank": 0.007025647351207999,
- "hotspot_count": 0,
- "dead_count": 7,
- "has_decision": true,
- "doc_coverage_pct": 0,
- "languages": [
- "python"
- ]
- },
- {
- "community_id": 1,
- "label": "flask",
- "cohesion": 0.5091,
- "member_count": 11,
- "top_file": "src/flask/globals.py",
- "avg_pagerank": 0.02957310326458718,
- "hotspot_count": 0,
- "dead_count": 0,
- "has_decision": true,
- "doc_coverage_pct": 0,
- "languages": [
- "python"
- ]
- },
- {
- "community_id": 2,
- "label": "flask/sansio",
- "cohesion": 0.3333,
- "member_count": 9,
- "top_file": "src/flask/sansio/app.py",
- "avg_pagerank": 0.010039298404646381,
- "hotspot_count": 0,
- "dead_count": 0,
- "has_decision": true,
- "doc_coverage_pct": 0,
- "languages": [
- "python"
- ]
- }
- ],
- "edges": [
- {
- "source": 26,
- "target": 0,
- "edge_count": 1
- },
- {
- "source": 0,
- "target": 1,
- "edge_count": 17
- },
- {
- "source": 0,
- "target": 3,
- "edge_count": 11
- },
- {
- "source": 1,
- "target": 2,
- "edge_count": 9
- },
- {
- "source": 1,
- "target": 3,
- "edge_count": 10
- },
- {
- "source": 0,
- "target": 2,
- "edge_count": 8
- },
- {
- "source": 3,
- "target": 0,
- "edge_count": 9
- },
- {
- "source": 2,
- "target": 1,
- "edge_count": 8
- },
- {
- "source": 2,
- "target": 0,
- "edge_count": 7
- },
- {
- "source": 2,
- "target": 3,
- "edge_count": 3
- },
- {
- "source": 3,
- "target": 1,
- "edge_count": 8
- },
- {
- "source": 1,
- "target": 0,
- "edge_count": 1
- },
- {
- "source": 3,
- "target": 26,
- "edge_count": 1
- }
- ]
-}
diff --git a/packages/api-client/src/__fixtures__/hosted/c4-l1.json b/packages/api-client/src/__fixtures__/hosted/c4-l1.json
deleted file mode 100644
index e8639c0d9..000000000
--- a/packages/api-client/src/__fixtures__/hosted/c4-l1.json
+++ /dev/null
@@ -1,449 +0,0 @@
-{
- "system": {
- "id": "sys:291eda74d214461487a07d63c4276cb3",
- "name": "flask",
- "description": ""
- },
- "people": [
- {
- "id": "person:cli",
- "name": "CLI user",
- "description": "Runs commands from a terminal",
- "kind": "cli"
- },
- {
- "id": "person:api",
- "name": "API client",
- "description": "Calls the HTTP API",
- "kind": "api"
- }
- ],
- "external_systems": [
- {
- "id": "ext:amqp",
- "name": "amqp",
- "display_name": "Amqp",
- "category": "library",
- "ecosystem": "pypi",
- "version": "==5.1.1",
- "io_kind": null
- },
- {
- "id": "ext:asgiref",
- "name": "asgiref",
- "display_name": "Asgiref",
- "category": "library",
- "ecosystem": "pypi",
- "version": ">=3.2",
- "io_kind": null
- },
- {
- "id": "ext:async-timeout",
- "name": "async-timeout",
- "display_name": "Async Timeout",
- "category": "library",
- "ecosystem": "pypi",
- "version": "==4.0.2",
- "io_kind": null
- },
- {
- "id": "ext:billiard",
- "name": "billiard",
- "display_name": "Billiard",
- "category": "library",
- "ecosystem": "pypi",
- "version": "==3.6.4.0",
- "io_kind": null
- },
- {
- "id": "ext:blinker",
- "name": "blinker",
- "display_name": "Blinker",
- "category": "library",
- "ecosystem": "pypi",
- "version": ">=1.9.0",
- "io_kind": null
- },
- {
- "id": "ext:celery",
- "name": "celery",
- "display_name": "Celery",
- "category": "library",
- "ecosystem": "pypi",
- "version": null,
- "io_kind": null
- },
- {
- "id": "ext:click",
- "name": "click",
- "display_name": "Click",
- "category": "library",
- "ecosystem": "pypi",
- "version": ">=8.1.3",
- "io_kind": null
- },
- {
- "id": "ext:click-didyoumean",
- "name": "click-didyoumean",
- "display_name": "Click Didyoumean",
- "category": "library",
- "ecosystem": "pypi",
- "version": "==0.3.0",
- "io_kind": null
- },
- {
- "id": "ext:click-plugins",
- "name": "click-plugins",
- "display_name": "Click Plugins",
- "category": "library",
- "ecosystem": "pypi",
- "version": "==1.1.1",
- "io_kind": null
- },
- {
- "id": "ext:click-repl",
- "name": "click-repl",
- "display_name": "Click Repl",
- "category": "library",
- "ecosystem": "pypi",
- "version": "==0.2.0",
- "io_kind": null
- },
- {
- "id": "ext:flask",
- "name": "flask",
- "display_name": "Flask",
- "category": "framework",
- "ecosystem": "pypi",
- "version": null,
- "io_kind": null
- },
- {
- "id": "ext:itsdangerous",
- "name": "itsdangerous",
- "display_name": "Itsdangerous",
- "category": "library",
- "ecosystem": "pypi",
- "version": ">=2.2.0",
- "io_kind": null
- },
- {
- "id": "ext:jinja2",
- "name": "jinja2",
- "display_name": "Jinja2",
- "category": "library",
- "ecosystem": "pypi",
- "version": ">=3.1.2",
- "io_kind": null
- },
- {
- "id": "ext:kombu",
- "name": "kombu",
- "display_name": "Kombu",
- "category": "library",
- "ecosystem": "pypi",
- "version": "==5.2.4",
- "io_kind": null
- },
- {
- "id": "ext:markupsafe",
- "name": "markupsafe",
- "display_name": "Markupsafe",
- "category": "library",
- "ecosystem": "pypi",
- "version": ">=2.1.1",
- "io_kind": null
- },
- {
- "id": "ext:prompt-toolkit",
- "name": "prompt-toolkit",
- "display_name": "Prompt Toolkit",
- "category": "library",
- "ecosystem": "pypi",
- "version": "==3.0.38",
- "io_kind": null
- },
- {
- "id": "ext:pytest",
- "name": "pytest",
- "display_name": "Pytest",
- "category": "tool",
- "ecosystem": "pypi",
- "version": null,
- "io_kind": null
- },
- {
- "id": "ext:python-dotenv",
- "name": "python-dotenv",
- "display_name": "Python Dotenv",
- "category": "library",
- "ecosystem": "pypi",
- "version": null,
- "io_kind": null
- },
- {
- "id": "ext:pytz",
- "name": "pytz",
- "display_name": "Pytz",
- "category": "library",
- "ecosystem": "pypi",
- "version": "==2023.3",
- "io_kind": null
- },
- {
- "id": "ext:redis",
- "name": "redis",
- "display_name": "Redis",
- "category": "service",
- "ecosystem": "pypi",
- "version": "==4.5.4",
- "io_kind": "db"
- },
- {
- "id": "ext:six",
- "name": "six",
- "display_name": "Six",
- "category": "library",
- "ecosystem": "pypi",
- "version": "==1.16.0",
- "io_kind": null
- },
- {
- "id": "ext:vine",
- "name": "vine",
- "display_name": "Vine",
- "category": "library",
- "ecosystem": "pypi",
- "version": "==5.0.0",
- "io_kind": null
- },
- {
- "id": "ext:wcwidth",
- "name": "wcwidth",
- "display_name": "Wcwidth",
- "category": "library",
- "ecosystem": "pypi",
- "version": "==0.2.6",
- "io_kind": null
- },
- {
- "id": "ext:werkzeug",
- "name": "werkzeug",
- "display_name": "Werkzeug",
- "category": "library",
- "ecosystem": "pypi",
- "version": ">=3.1.0",
- "io_kind": null
- }
- ],
- "relations": [
- {
- "source_id": "person:cli",
- "target_id": "sys:291eda74d214461487a07d63c4276cb3",
- "label": "runs",
- "edge_count": 1,
- "edge_types": [],
- "coupling": ""
- },
- {
- "source_id": "person:api",
- "target_id": "sys:291eda74d214461487a07d63c4276cb3",
- "label": "calls",
- "edge_count": 1,
- "edge_types": [],
- "coupling": ""
- },
- {
- "source_id": "sys:291eda74d214461487a07d63c4276cb3",
- "target_id": "ext:amqp",
- "label": "library",
- "edge_count": 1,
- "edge_types": [],
- "coupling": ""
- },
- {
- "source_id": "sys:291eda74d214461487a07d63c4276cb3",
- "target_id": "ext:asgiref",
- "label": "library",
- "edge_count": 1,
- "edge_types": [],
- "coupling": ""
- },
- {
- "source_id": "sys:291eda74d214461487a07d63c4276cb3",
- "target_id": "ext:async-timeout",
- "label": "library",
- "edge_count": 1,
- "edge_types": [],
- "coupling": ""
- },
- {
- "source_id": "sys:291eda74d214461487a07d63c4276cb3",
- "target_id": "ext:billiard",
- "label": "library",
- "edge_count": 1,
- "edge_types": [],
- "coupling": ""
- },
- {
- "source_id": "sys:291eda74d214461487a07d63c4276cb3",
- "target_id": "ext:blinker",
- "label": "library",
- "edge_count": 1,
- "edge_types": [],
- "coupling": ""
- },
- {
- "source_id": "sys:291eda74d214461487a07d63c4276cb3",
- "target_id": "ext:celery",
- "label": "library",
- "edge_count": 1,
- "edge_types": [],
- "coupling": ""
- },
- {
- "source_id": "sys:291eda74d214461487a07d63c4276cb3",
- "target_id": "ext:click",
- "label": "library",
- "edge_count": 1,
- "edge_types": [],
- "coupling": ""
- },
- {
- "source_id": "sys:291eda74d214461487a07d63c4276cb3",
- "target_id": "ext:click-didyoumean",
- "label": "library",
- "edge_count": 1,
- "edge_types": [],
- "coupling": ""
- },
- {
- "source_id": "sys:291eda74d214461487a07d63c4276cb3",
- "target_id": "ext:click-plugins",
- "label": "library",
- "edge_count": 1,
- "edge_types": [],
- "coupling": ""
- },
- {
- "source_id": "sys:291eda74d214461487a07d63c4276cb3",
- "target_id": "ext:click-repl",
- "label": "library",
- "edge_count": 1,
- "edge_types": [],
- "coupling": ""
- },
- {
- "source_id": "sys:291eda74d214461487a07d63c4276cb3",
- "target_id": "ext:flask",
- "label": "framework",
- "edge_count": 1,
- "edge_types": [],
- "coupling": ""
- },
- {
- "source_id": "sys:291eda74d214461487a07d63c4276cb3",
- "target_id": "ext:itsdangerous",
- "label": "library",
- "edge_count": 1,
- "edge_types": [],
- "coupling": ""
- },
- {
- "source_id": "sys:291eda74d214461487a07d63c4276cb3",
- "target_id": "ext:jinja2",
- "label": "library",
- "edge_count": 1,
- "edge_types": [],
- "coupling": ""
- },
- {
- "source_id": "sys:291eda74d214461487a07d63c4276cb3",
- "target_id": "ext:kombu",
- "label": "library",
- "edge_count": 1,
- "edge_types": [],
- "coupling": ""
- },
- {
- "source_id": "sys:291eda74d214461487a07d63c4276cb3",
- "target_id": "ext:markupsafe",
- "label": "library",
- "edge_count": 1,
- "edge_types": [],
- "coupling": ""
- },
- {
- "source_id": "sys:291eda74d214461487a07d63c4276cb3",
- "target_id": "ext:prompt-toolkit",
- "label": "library",
- "edge_count": 1,
- "edge_types": [],
- "coupling": ""
- },
- {
- "source_id": "sys:291eda74d214461487a07d63c4276cb3",
- "target_id": "ext:pytest",
- "label": "tool",
- "edge_count": 1,
- "edge_types": [],
- "coupling": ""
- },
- {
- "source_id": "sys:291eda74d214461487a07d63c4276cb3",
- "target_id": "ext:python-dotenv",
- "label": "library",
- "edge_count": 1,
- "edge_types": [],
- "coupling": ""
- },
- {
- "source_id": "sys:291eda74d214461487a07d63c4276cb3",
- "target_id": "ext:pytz",
- "label": "library",
- "edge_count": 1,
- "edge_types": [],
- "coupling": ""
- },
- {
- "source_id": "sys:291eda74d214461487a07d63c4276cb3",
- "target_id": "ext:redis",
- "label": "service",
- "edge_count": 1,
- "edge_types": [],
- "coupling": ""
- },
- {
- "source_id": "sys:291eda74d214461487a07d63c4276cb3",
- "target_id": "ext:six",
- "label": "library",
- "edge_count": 1,
- "edge_types": [],
- "coupling": ""
- },
- {
- "source_id": "sys:291eda74d214461487a07d63c4276cb3",
- "target_id": "ext:vine",
- "label": "library",
- "edge_count": 1,
- "edge_types": [],
- "coupling": ""
- },
- {
- "source_id": "sys:291eda74d214461487a07d63c4276cb3",
- "target_id": "ext:wcwidth",
- "label": "library",
- "edge_count": 1,
- "edge_types": [],
- "coupling": ""
- },
- {
- "source_id": "sys:291eda74d214461487a07d63c4276cb3",
- "target_id": "ext:werkzeug",
- "label": "library",
- "edge_count": 1,
- "edge_types": [],
- "coupling": ""
- }
- ]
-}
diff --git a/packages/api-client/src/__fixtures__/hosted/churn-complexity.json b/packages/api-client/src/__fixtures__/hosted/churn-complexity.json
deleted file mode 100644
index e9c69a4f5..000000000
--- a/packages/api-client/src/__fixtures__/hosted/churn-complexity.json
+++ /dev/null
@@ -1,30 +0,0 @@
-{
- "points": [
- {
- "file_path": "src/flask/cli.py",
- "commit_count_90d": 2,
- "max_ccn": 13,
- "nloc": 822,
- "score": 2.05,
- "churn_percentile": 84.5
- },
- {
- "file_path": "src/flask/sansio/app.py",
- "commit_count_90d": 1,
- "max_ccn": 12,
- "nloc": 678,
- "score": 1.35,
- "churn_percentile": 94
- },
- {
- "file_path": "src/flask/ctx.py",
- "commit_count_90d": 1,
- "max_ccn": 7,
- "nloc": 395,
- "score": 6.51,
- "churn_percentile": 97.6
- }
- ],
- "total_points": 4,
- "state": "ready"
-}
diff --git a/packages/api-client/src/__fixtures__/hosted/coupling.json b/packages/api-client/src/__fixtures__/hosted/coupling.json
deleted file mode 100644
index 9a7be4d46..000000000
--- a/packages/api-client/src/__fixtures__/hosted/coupling.json
+++ /dev/null
@@ -1,38 +0,0 @@
-{
- "nodes": [
- {
- "file_path": "CHANGES.rst",
- "module": null,
- "score": null,
- "nloc": 0
- },
- {
- "file_path": "src/flask/app.py",
- "module": "flask",
- "score": 1.07,
- "nloc": 1235
- },
- {
- "file_path": "src/flask/sansio/app.py",
- "module": "flask/sansio",
- "score": 1.35,
- "nloc": 678
- }
- ],
- "edges": [
- {
- "source": "CHANGES.rst",
- "target": "src/flask/sansio/app.py",
- "strength": 2.66,
- "last_co_change": "2026-05-02"
- },
- {
- "source": "CHANGES.rst",
- "target": "src/flask/app.py",
- "strength": 2.05,
- "last_co_change": "2026-02-20"
- }
- ],
- "total_edges": 2,
- "state": "ready"
-}
diff --git a/packages/api-client/src/__fixtures__/hosted/dead-code.json b/packages/api-client/src/__fixtures__/hosted/dead-code.json
deleted file mode 100644
index 02a2ab54e..000000000
--- a/packages/api-client/src/__fixtures__/hosted/dead-code.json
+++ /dev/null
@@ -1,46 +0,0 @@
-{
- "total_findings": 28,
- "deletable_lines": 169,
- "findings": [
- {
- "kind": "unreachable_file",
- "file_path": "docs/conf.py",
- "symbol_name": null,
- "symbol_kind": null,
- "confidence": 0.4,
- "reason": "File has no importers (in_degree=0)",
- "last_commit_at": "2025-06-12T20:46:49+00:00",
- "commit_count_90d": 0,
- "lines": 240,
- "package": "docs",
- "evidence": [
- "in_degree=0 (no files import this)",
- "No commits in last 90 days",
- "Package uses dynamic imports or runtime-resolved edges",
- "Runtime-load risk (configuration): files of this kind are often referenced outside static imports — review before deleting"
- ],
- "safe_to_delete": false,
- "primary_owner": "David Lord",
- "age_days": 3734
- },
- {
- "kind": "unreachable_file",
- "file_path": "examples/celery/make_celery.py",
- "symbol_name": null,
- "symbol_kind": null,
- "confidence": 1,
- "reason": "File has no importers (in_degree=0)",
- "last_commit_at": "2023-02-10T17:16:53+00:00",
- "commit_count_90d": 0,
- "lines": 20,
- "package": "examples",
- "evidence": [
- "in_degree=0 (no files import this)",
- "No commits in last 90 days"
- ],
- "safe_to_delete": true,
- "primary_owner": "David Lord",
- "age_days": 1239
- }
- ]
-}
diff --git a/packages/api-client/src/__fixtures__/hosted/decisions.json b/packages/api-client/src/__fixtures__/hosted/decisions.json
deleted file mode 100644
index d68c5e585..000000000
--- a/packages/api-client/src/__fixtures__/hosted/decisions.json
+++ /dev/null
@@ -1,106 +0,0 @@
-{
- "total_found": 32,
- "decisions": [
- {
- "id": "9827083f96ad4d149c9d983a7e59a9bc",
- "title": "Windows env var keys are always uppercase.",
- "context": "In `tests.test_config.test_from_prefixed_env_nested` (tests/test_config.py:97)",
- "decision": "Windows env var keys are always uppercase.",
- "rationale": "",
- "alternatives": [],
- "consequences": [],
- "affected_files": [
- "tests/test_config.py"
- ],
- "affected_modules": [
- "tests"
- ],
- "tags": [],
- "source": "code_comment",
- "evidence_commits": [],
- "evidence_file": "tests/test_config.py",
- "evidence_line": 97,
- "confidence": 0.511,
- "status": "proposed",
- "verification": "exact",
- "source_quote": "Windows env var keys are always uppercase.",
- "staleness_score": 0,
- "superseded_by": null,
- "last_code_change": null,
- "evidence": [
- {
- "source": "code_comment",
- "source_rank": 2,
- "evidence_file": "tests/test_config.py",
- "evidence_line": 97,
- "evidence_commit": null,
- "source_quote": "Windows env var keys are always uppercase.",
- "confidence": 0.3,
- "verification": "exact"
- }
- ],
- "evidence_count": 1,
- "evidence_preview": {
- "source": "code_comment",
- "source_quote": "Windows env var keys are always uppercase.",
- "verification": "exact",
- "evidence_file": "tests/test_config.py",
- "evidence_line": 97
- }
- },
- {
- "id": "d4175eb5203c426abeb80cd320a55136",
- "title": "do this instead of startswith for nicer pytest output",
- "context": "In `tests.test_cli.TestRoutes.expect_order` (tests/test_cli.py:466)",
- "decision": "do this instead of startswith for nicer pytest output",
- "rationale": "",
- "alternatives": [],
- "consequences": [],
- "affected_files": [
- "tests/test_cli.py"
- ],
- "affected_modules": [
- "tests"
- ],
- "tags": [
- "testing"
- ],
- "source": "code_comment",
- "evidence_commits": [],
- "evidence_file": "tests/test_cli.py",
- "evidence_line": 466,
- "confidence": 0.511,
- "status": "proposed",
- "verification": "exact",
- "source_quote": "do this instead of startswith for nicer pytest output",
- "staleness_score": 0,
- "superseded_by": null,
- "last_code_change": null,
- "evidence": [
- {
- "source": "code_comment",
- "source_rank": 2,
- "evidence_file": "tests/test_cli.py",
- "evidence_line": 466,
- "evidence_commit": null,
- "source_quote": "do this instead of startswith for nicer pytest output",
- "confidence": 0.3,
- "verification": "exact"
- }
- ],
- "evidence_count": 1,
- "evidence_preview": {
- "source": "code_comment",
- "source_quote": "do this instead of startswith for nicer pytest output",
- "verification": "exact",
- "evidence_file": "tests/test_cli.py",
- "evidence_line": 466
- }
- }
- ],
- "by_source": {
- "code_comment": 24,
- "comment": 4,
- "pr": 4
- }
-}
diff --git a/packages/api-client/src/__fixtures__/hosted/docs.json b/packages/api-client/src/__fixtures__/hosted/docs.json
deleted file mode 100644
index 0e95b9388..000000000
--- a/packages/api-client/src/__fixtures__/hosted/docs.json
+++ /dev/null
@@ -1,89 +0,0 @@
-{
- "available": true,
- "pages": [
- {
- "page_id": "api_contract:packages/core/src/repowise/core/ingestion/languages/specs/openapi.py",
- "page_type": "api_contract",
- "title": "API Contract: packages/core/src/repowise/core/ingestion/languages/specs/openapi.py",
- "content": "## Overview\n\nThis API contract defines a **language specification** for **OpenAPI** within the Repowise ingestion system. It does **not** declare any HTTP endpoints or data schemas itself; instead, it configures how the ingestion pipeline should treat OpenAPI inputs.\n\nKey characteristics of this lan",
- "target_path": "packages/core/src/repowise/core/ingestion/languages/specs/openapi.py",
- "freshness_status": "fresh",
- "source_hash": "8edc971707061718d2ed7ead86300977b3bb4d843f3af13938d665c26f8ff35b",
- "model_name": "gpt-5.4-nano",
- "provider_name": "openai",
- "input_tokens": 0,
- "output_tokens": 0,
- "generation_level": 0,
- "confidence": 1,
- "created_at": "2026-07-04T15:16:00.959140+00:00",
- "updated_at": "2026-07-04T15:16:00.959140+00:00",
- "summary": "This API contract defines a **language specification** for **OpenAPI** within the Repowise ingestion system. It does **not** declare any HTTP endpoints or data schemas itself; instead, it configures how the ingestion pipeline should treat OpenAPI inputs.",
- "metadata": {
- "wiki_links": [],
- "backlinks": [
- {
- "source_page_id": "file_page:packages/core/src/repowise/core/ingestion/languages/specs/__init__.py",
- "source_title": "File: packages/core/src/repowise/core/ingestion/languages/specs/__init__.py",
- "source_page_type": "file_page",
- "anchor": "SPEC"
- },
- {
- "source_page_id": "module_page:packages/core/src/repowise/core/ingestion/languages",
- "source_title": "Module: ingestion/languages",
- "source_page_type": "module_page",
- "anchor": "SPEC"
- },
- {
- "source_page_id": "layer_page:layer:service",
- "source_title": "Layer: Service",
- "source_page_type": "layer_page",
- "anchor": "SPEC"
- },
- {
- "source_page_id": "onboarding:onboarding/key_concepts",
- "source_title": "Key Concepts",
- "source_page_type": "onboarding",
- "anchor": "SPEC"
- }
- ]
- },
- "id": "api_contract:packages/core/src/repowise/core/ingestion/languages/specs/openapi.py"
- },
- {
- "page_id": "symbol_spotlight:tests/conftest.py::repo_root",
- "page_type": "symbol_spotlight",
- "title": "Symbol: tests.conftest.repo_root",
- "content": "## Purpose\n\n`repo_root` is a session-scoped pytest fixture that returns the absolute filesystem path to the repository’s root directory. It is used throughout the test suite to reliably locate files and resources relative to the project root, regardless of the current working directory.\n\n## Signatur",
- "target_path": "tests/conftest.py::repo_root",
- "freshness_status": "fresh",
- "source_hash": "b71ffe24c2c9096841740a4a0274f75603afc2a879e7a694cbf6a1450a464b9e",
- "model_name": "gpt-5.4-nano",
- "provider_name": "openai",
- "input_tokens": 6808,
- "output_tokens": 152,
- "generation_level": 1,
- "confidence": 1,
- "created_at": "2026-07-04T15:16:04.157142+00:00",
- "updated_at": "2026-07-04T15:16:04.157142+00:00",
- "summary": "`repo_root` is a session-scoped pytest fixture that returns the absolute filesystem path to the repository’s root directory. It is used throughout the test suite to reliably locate files and resources relative to the project root, regardless of the current working directory.",
- "metadata": {
- "wiki_links": [
- {
- "anchor": "repo_root",
- "target_page_id": "file_page:tests/conftest.py",
- "kind": "symbol"
- }
- ],
- "backlinks": []
- },
- "id": "symbol_spotlight:tests/conftest.py::repo_root"
- }
- ],
- "docs_status": "ready",
- "pages_ready": 523,
- "pages_total": 523,
- "authoritative_page_types": [
- "module_page",
- "layer_page"
- ]
-}
diff --git a/packages/api-client/src/__fixtures__/hosted/execution-flows.json b/packages/api-client/src/__fixtures__/hosted/execution-flows.json
deleted file mode 100644
index 411150511..000000000
--- a/packages/api-client/src/__fixtures__/hosted/execution-flows.json
+++ /dev/null
@@ -1,406 +0,0 @@
-{
- "total_entry_points": 39,
- "flows": [
- {
- "entry_point": "src/flask/app.py::Flask::do_teardown_request",
- "entry_point_name": "do_teardown_request",
- "entry_point_score": 0.8383,
- "trace": [
- "src/flask/app.py::Flask::do_teardown_request",
- "src/flask/app.py::Flask::ensure_sync",
- "src/flask/app.py::Flask::async_to_sync"
- ],
- "depth": 2,
- "crosses_community": false,
- "communities_visited": [
- 0
- ]
- },
- {
- "entry_point": "src/flask/app.py::Flask::do_teardown_appcontext",
- "entry_point_name": "do_teardown_appcontext",
- "entry_point_score": 0.8383,
- "trace": [
- "src/flask/app.py::Flask::do_teardown_appcontext",
- "src/flask/app.py::Flask::ensure_sync",
- "src/flask/app.py::Flask::async_to_sync"
- ],
- "depth": 2,
- "crosses_community": false,
- "communities_visited": [
- 0
- ]
- },
- {
- "entry_point": "src/flask/app.py::Flask::__init_subclass__",
- "entry_point_name": "__init_subclass__",
- "entry_point_score": 0.7483,
- "trace": [
- "src/flask/app.py::Flask::__init_subclass__",
- "src/flask/app.py::add_ctx",
- "src/flask/globals.py::ProxyMixin::_get_current_object"
- ],
- "depth": 2,
- "crosses_community": false,
- "communities_visited": [
- 12
- ]
- },
- {
- "entry_point": "src/flask/templating.py::DispatchingJinjaLoader::get_source",
- "entry_point_name": "get_source",
- "entry_point_score": 0.7433,
- "trace": [
- "src/flask/templating.py::DispatchingJinjaLoader::get_source",
- "src/flask/templating.py::DispatchingJinjaLoader::_get_source_explained",
- "src/flask/debughelpers.py::explain_template_loading_attempts",
- "src/flask/debughelpers.py::_dump_loader_info"
- ],
- "depth": 3,
- "crosses_community": false,
- "communities_visited": [
- 17
- ]
- },
- {
- "entry_point": "src/flask/blueprints.py::Blueprint::send_static_file",
- "entry_point_name": "send_static_file",
- "entry_point_score": 0.7433,
- "trace": [
- "src/flask/blueprints.py::Blueprint::send_static_file",
- "src/flask/helpers.py::send_from_directory",
- "src/flask/helpers.py::_prepare_send_file_kwargs",
- "src/flask/globals.py::ProxyMixin::_get_current_object"
- ],
- "depth": 3,
- "crosses_community": true,
- "communities_visited": [
- 7,
- 12
- ]
- },
- {
- "entry_point": "src/flask/testing.py::FlaskClient::open",
- "entry_point_name": "open",
- "entry_point_score": 0.7275,
- "trace": [
- "src/flask/testing.py::FlaskClient::open",
- "src/flask/testing.py::FlaskClient::_request_from_builder_args",
- "src/flask/testing.py::FlaskClient::_copy_environ"
- ],
- "depth": 2,
- "crosses_community": false,
- "communities_visited": [
- 9
- ]
- },
- {
- "entry_point": "src/flask/testing.py::FlaskClient::__init__",
- "entry_point_name": "__init__",
- "entry_point_score": 0.6983,
- "trace": [
- "src/flask/testing.py::FlaskClient::__init__",
- "src/flask/testing.py::FlaskCliRunner::__init__",
- "src/flask/app.py::Flask::__init__",
- "src/flask/app.py::Flask::send_static_file",
- "src/flask/helpers.py::send_from_directory",
- "src/flask/helpers.py::_prepare_send_file_kwargs",
- "src/flask/globals.py::ProxyMixin::_get_current_object"
- ],
- "depth": 6,
- "crosses_community": true,
- "communities_visited": [
- 9,
- 0,
- 12
- ]
- },
- {
- "entry_point": "src/flask/sessions.py::SecureCookieSessionInterface::save_session",
- "entry_point_name": "save_session",
- "entry_point_score": 0.6983,
- "trace": [
- "src/flask/sessions.py::SecureCookieSessionInterface::save_session",
- "src/flask/json/tag.py::TaggedJSONSerializer::dumps",
- "src/flask/json/__init__.py::dumps"
- ],
- "depth": 2,
- "crosses_community": true,
- "communities_visited": [
- 11,
- 5
- ]
- },
- {
- "entry_point": "src/flask/json/tag.py::TaggedJSONSerializer::loads",
- "entry_point_name": "loads",
- "entry_point_score": 0.6983,
- "trace": [
- "src/flask/json/tag.py::TaggedJSONSerializer::loads",
- "src/flask/json/tag.py::TaggedJSONSerializer::_untag_scan",
- "src/flask/json/tag.py::TaggedJSONSerializer::untag"
- ],
- "depth": 2,
- "crosses_community": false,
- "communities_visited": [
- 5
- ]
- },
- {
- "entry_point": "src/flask/templating.py::stream_template_string",
- "entry_point_name": "stream_template_string",
- "entry_point_score": 0.6983,
- "trace": [
- "src/flask/templating.py::stream_template_string",
- "src/flask/templating.py::_stream",
- "src/flask/helpers.py::stream_with_context"
- ],
- "depth": 2,
- "crosses_community": false,
- "communities_visited": [
- 12
- ]
- },
- {
- "entry_point": "src/flask/sansio/blueprints.py::Blueprint::register",
- "entry_point_name": "register",
- "entry_point_score": 0.6983,
- "trace": [
- "src/flask/sansio/blueprints.py::Blueprint::register",
- "src/flask/sansio/blueprints.py::Blueprint::make_setup_state",
- "src/flask/sansio/blueprints.py::BlueprintSetupState"
- ],
- "depth": 2,
- "crosses_community": false,
- "communities_visited": [
- 8
- ]
- },
- {
- "entry_point": "src/flask/app.py::Flask::handle_exception",
- "entry_point_name": "handle_exception",
- "entry_point_score": 0.69,
- "trace": [
- "src/flask/app.py::Flask::handle_exception",
- "src/flask/app.py::Flask::finalize_request",
- "src/flask/app.py::Flask::process_response",
- "src/flask/app.py::Flask::ensure_sync",
- "src/flask/app.py::Flask::async_to_sync"
- ],
- "depth": 4,
- "crosses_community": false,
- "communities_visited": [
- 0
- ]
- },
- {
- "entry_point": "src/flask/app.py::Flask::dispatch_request",
- "entry_point_name": "dispatch_request",
- "entry_point_score": 0.69,
- "trace": [
- "src/flask/app.py::Flask::dispatch_request",
- "src/flask/app.py::Flask::raise_routing_exception",
- "src/flask/debughelpers.py::FormDataRoutingRedirect"
- ],
- "depth": 2,
- "crosses_community": true,
- "communities_visited": [
- 0,
- 7
- ]
- },
- {
- "entry_point": "src/flask/app.py::Flask::handle_user_exception",
- "entry_point_name": "handle_user_exception",
- "entry_point_score": 0.655,
- "trace": [
- "src/flask/app.py::Flask::handle_user_exception",
- "src/flask/app.py::Flask::handle_http_exception",
- "src/flask/app.py::Flask::ensure_sync",
- "src/flask/app.py::Flask::async_to_sync"
- ],
- "depth": 3,
- "crosses_community": false,
- "communities_visited": [
- 0
- ]
- },
- {
- "entry_point": "src/flask/app.py::Flask::full_dispatch_request",
- "entry_point_name": "full_dispatch_request",
- "entry_point_score": 0.6233,
- "trace": [
- "src/flask/app.py::Flask::full_dispatch_request",
- "src/flask/app.py::Flask::dispatch_request",
- "src/flask/app.py::Flask::raise_routing_exception",
- "src/flask/debughelpers.py::FormDataRoutingRedirect"
- ],
- "depth": 3,
- "crosses_community": true,
- "communities_visited": [
- 0,
- 7
- ]
- },
- {
- "entry_point": "src/flask/app.py::Flask::send_static_file",
- "entry_point_name": "send_static_file",
- "entry_point_score": 0.61,
- "trace": [
- "src/flask/app.py::Flask::send_static_file",
- "src/flask/helpers.py::send_from_directory",
- "src/flask/helpers.py::_prepare_send_file_kwargs",
- "src/flask/globals.py::ProxyMixin::_get_current_object"
- ],
- "depth": 3,
- "crosses_community": true,
- "communities_visited": [
- 0,
- 12
- ]
- },
- {
- "entry_point": "src/flask/app.py::Flask::wsgi_app",
- "entry_point_name": "wsgi_app",
- "entry_point_score": 0.6,
- "trace": [
- "src/flask/app.py::Flask::wsgi_app",
- "src/flask/app.py::Flask::full_dispatch_request",
- "src/flask/app.py::Flask::dispatch_request",
- "src/flask/app.py::Flask::raise_routing_exception",
- "src/flask/debughelpers.py::FormDataRoutingRedirect"
- ],
- "depth": 4,
- "crosses_community": true,
- "communities_visited": [
- 0,
- 7
- ]
- },
- {
- "entry_point": "src/flask/cli.py::ScriptInfo::load_app",
- "entry_point_name": "load_app",
- "entry_point_score": 0.5733,
- "trace": [
- "src/flask/cli.py::ScriptInfo::load_app",
- "src/flask/cli.py::locate_app",
- "src/flask/cli.py::find_best_app",
- "src/flask/cli.py::NoAppException"
- ],
- "depth": 3,
- "crosses_community": false,
- "communities_visited": [
- 3
- ]
- },
- {
- "entry_point": "src/flask/app.py::Flask::test_request_context",
- "entry_point_name": "test_request_context",
- "entry_point_score": 0.565,
- "trace": [
- "src/flask/app.py::Flask::test_request_context",
- "src/flask/app.py::Flask::request_context",
- "src/flask/ctx.py::AppContext::from_environ"
- ],
- "depth": 2,
- "crosses_community": false,
- "communities_visited": [
- 0
- ]
- },
- {
- "entry_point": "src/flask/templating.py::stream_template",
- "entry_point_name": "stream_template",
- "entry_point_score": 0.515,
- "trace": [
- "src/flask/templating.py::stream_template",
- "src/flask/templating.py::_stream",
- "src/flask/helpers.py::stream_with_context"
- ],
- "depth": 2,
- "crosses_community": false,
- "communities_visited": [
- 12
- ]
- },
- {
- "entry_point": "src/flask/app.py::Flask::__init__",
- "entry_point_name": "__init__",
- "entry_point_score": 0.44,
- "trace": [
- "src/flask/app.py::Flask::__init__",
- "src/flask/app.py::Flask::send_static_file",
- "src/flask/helpers.py::send_from_directory",
- "src/flask/helpers.py::_prepare_send_file_kwargs",
- "src/flask/globals.py::ProxyMixin::_get_current_object"
- ],
- "depth": 4,
- "crosses_community": true,
- "communities_visited": [
- 0,
- 12
- ]
- },
- {
- "entry_point": "src/flask/app.py::Flask::finalize_request",
- "entry_point_name": "finalize_request",
- "entry_point_score": 0.405,
- "trace": [
- "src/flask/app.py::Flask::finalize_request",
- "src/flask/app.py::Flask::process_response",
- "src/flask/app.py::Flask::ensure_sync",
- "src/flask/app.py::Flask::async_to_sync"
- ],
- "depth": 3,
- "crosses_community": false,
- "communities_visited": [
- 0
- ]
- },
- {
- "entry_point": "src/flask/cli.py::locate_app",
- "entry_point_name": "locate_app",
- "entry_point_score": 0.3463,
- "trace": [
- "src/flask/cli.py::locate_app",
- "src/flask/cli.py::find_best_app",
- "src/flask/cli.py::NoAppException"
- ],
- "depth": 2,
- "crosses_community": false,
- "communities_visited": [
- 3
- ]
- },
- {
- "entry_point": "src/flask/wrappers.py::Request::_load_form_data",
- "entry_point_name": "_load_form_data",
- "entry_point_score": 0.315,
- "trace": [
- "src/flask/wrappers.py::Request::_load_form_data",
- "src/flask/debughelpers.py::attach_enctype_error_multidict",
- "src/flask/debughelpers.py::DebugFilesKeyError"
- ],
- "depth": 2,
- "crosses_community": false,
- "communities_visited": [
- 13
- ]
- },
- {
- "entry_point": "src/flask/templating.py::DispatchingJinjaLoader::_get_source_explained",
- "entry_point_name": "_get_source_explained",
- "entry_point_score": 0.315,
- "trace": [
- "src/flask/templating.py::DispatchingJinjaLoader::_get_source_explained",
- "src/flask/debughelpers.py::explain_template_loading_attempts",
- "src/flask/debughelpers.py::_dump_loader_info"
- ],
- "depth": 2,
- "crosses_community": false,
- "communities_visited": [
- 17
- ]
- }
- ]
-}
diff --git a/packages/api-client/src/__fixtures__/hosted/file-detail.json b/packages/api-client/src/__fixtures__/hosted/file-detail.json
deleted file mode 100644
index 269816248..000000000
--- a/packages/api-client/src/__fixtures__/hosted/file-detail.json
+++ /dev/null
@@ -1,61 +0,0 @@
-{
- "file_path": ".pre-commit-config.yaml",
- "wiki_page": null,
- "health": {
- "metric": {
- "file_path": ".pre-commit-config.yaml",
- "score": 10,
- "band": "excellent",
- "max_ccn": 1,
- "max_nesting": 0,
- "nloc": 23,
- "duplication_pct": null,
- "has_test_file": false,
- "line_coverage_pct": null,
- "branch_coverage_pct": null,
- "module": "config",
- "defect_score": 10,
- "maintainability_score": 10,
- "performance_score": 10,
- "top_biomarkers": []
- },
- "breakdown": {
- "file_path": ".pre-commit-config.yaml",
- "score": 10,
- "deductions_by_category": {},
- "findings": [],
- "suggestion": null,
- "state": "ready",
- "reason": null
- },
- "findings": []
- },
- "git": null,
- "coverage": null,
- "graph": {
- "language": "yaml",
- "is_entry_point": false,
- "is_test": false,
- "symbol_count": 0,
- "pagerank": 0.002136,
- "pagerank_percentile": 0,
- "in_degree": 0,
- "out_degree": 1,
- "community_id": 14,
- "community_label": null,
- "dependents": [],
- "dependencies": [
- {
- "node_id": ".pre-commit-config.yaml::__module__",
- "node_type": "symbol",
- "language": "yaml",
- "edge_type": "defines",
- "imported_names": []
- }
- ]
- },
- "symbols": [],
- "function_blame": [],
- "governing_decisions": [],
- "dead_code": []
-}
diff --git a/packages/api-client/src/__fixtures__/hosted/files-index.json b/packages/api-client/src/__fixtures__/hosted/files-index.json
deleted file mode 100644
index 0f905fd74..000000000
--- a/packages/api-client/src/__fixtures__/hosted/files-index.json
+++ /dev/null
@@ -1,78 +0,0 @@
-{
- "files": [
- {
- "file_path": ".pre-commit-config.yaml",
- "language": "yaml",
- "loc": 23,
- "symbol_count": 0,
- "pagerank_pct": 0,
- "in_degree": 0,
- "out_degree": 1,
- "defect_score": 10,
- "maintainability_score": 10,
- "performance_score": 10,
- "churn_pct": null,
- "commit_count": null,
- "last_commit_at": null,
- "coverage_pct": null,
- "is_test": false,
- "is_entry_point": false,
- "community_id": 14
- },
- {
- "file_path": ".readthedocs.yaml",
- "language": "yaml",
- "loc": 10,
- "symbol_count": 0,
- "pagerank_pct": 0,
- "in_degree": 0,
- "out_degree": 1,
- "defect_score": 10,
- "maintainability_score": 10,
- "performance_score": 10,
- "churn_pct": null,
- "commit_count": null,
- "last_commit_at": null,
- "coverage_pct": null,
- "is_test": false,
- "is_entry_point": false,
- "community_id": 15
- },
- {
- "file_path": "README.md",
- "language": "markdown",
- "loc": 38,
- "symbol_count": 0,
- "pagerank_pct": 0,
- "in_degree": 0,
- "out_degree": 1,
- "defect_score": 10,
- "maintainability_score": 10,
- "performance_score": 10,
- "churn_pct": null,
- "commit_count": null,
- "last_commit_at": null,
- "coverage_pct": null,
- "is_test": false,
- "is_entry_point": false,
- "community_id": 16
- }
- ],
- "language_counts": {
- "yaml": 8,
- "markdown": 6,
- "toml": 5,
- "shell": 1,
- "json": 2,
- "makefile": 1,
- "python": 83,
- "sql": 2
- },
- "totals": {
- "files": 108,
- "loc": 14043
- },
- "state": "ready",
- "reason": null,
- "items": []
-}
diff --git a/packages/api-client/src/__fixtures__/hosted/git-summary.json b/packages/api-client/src/__fixtures__/hosted/git-summary.json
deleted file mode 100644
index 8d7a7db4b..000000000
--- a/packages/api-client/src/__fixtures__/hosted/git-summary.json
+++ /dev/null
@@ -1,23 +0,0 @@
-{
- "total_files": 84,
- "hotspot_count": 0,
- "stable_count": 35,
- "average_churn_percentile": 49.404761904761905,
- "top_owners": [
- {
- "name": "David Lord",
- "file_count": 58,
- "pct": 0.6904761904761905
- },
- {
- "name": "Markus Unterwaditzer",
- "file_count": 5,
- "pct": 0.05952380952380952
- },
- {
- "name": "pgjones",
- "file_count": 4,
- "pct": 0.047619047619047616
- }
- ]
-}
diff --git a/packages/api-client/src/__fixtures__/hosted/health-files.json b/packages/api-client/src/__fixtures__/hosted/health-files.json
deleted file mode 100644
index dc405f3b1..000000000
--- a/packages/api-client/src/__fixtures__/hosted/health-files.json
+++ /dev/null
@@ -1,182 +0,0 @@
-[
- {
- "file_path": "src/flask/app.py",
- "score": 1.07,
- "band": "at_risk",
- "max_ccn": 16,
- "max_nesting": 5,
- "nloc": 1235,
- "duplication_pct": 10.42,
- "has_test_file": false,
- "line_coverage_pct": null,
- "branch_coverage_pct": null,
- "module": "flask",
- "defect_score": 1.07,
- "maintainability_score": 3.1,
- "performance_score": 9.7,
- "top_biomarkers": [
- {
- "id": "1633695362c7ee2ec41d4144",
- "biomarker_type": "untested_hotspot",
- "severity": "high",
- "file_path": "src/flask/app.py",
- "function_name": null,
- "line_start": null,
- "line_end": null,
- "details": {
- "line_coverage_pct": null,
- "branch_coverage_pct": null,
- "dependents_count": 6,
- "commit_count_90d": 0,
- "has_test_file": false
- },
- "health_impact": 1.56,
- "reason": "Hotspot with no paired test file and no coverage data — 6 dependents",
- "status": "open",
- "suggestion": "Hot file with low/no coverage — add tests against the most-changed methods first.",
- "dimension": "defect",
- "symbol_id": null
- },
- {
- "id": "a636c1b680c14f66696424f2",
- "biomarker_type": "function_hotspot",
- "severity": "high",
- "file_path": "src/flask/app.py",
- "function_name": "make_response",
- "line_start": 1224,
- "line_end": 1364,
- "details": {
- "modification_count": 6,
- "repo_p80": 5,
- "ccn": 16,
- "max_nesting": 5
- },
- "health_impact": 1.392,
- "reason": "make_response has been modified across 6 commits (repo p80=5) and carries CCN=16 / nesting=5",
- "status": "open",
- "suggestion": "Review and refactor according to the biomarker details.",
- "dimension": "defect",
- "symbol_id": null
- }
- ]
- },
- {
- "file_path": "src/flask/sansio/app.py",
- "score": 1.35,
- "band": "at_risk",
- "max_ccn": 12,
- "max_nesting": 4,
- "nloc": 678,
- "duplication_pct": 14.3,
- "has_test_file": false,
- "line_coverage_pct": null,
- "branch_coverage_pct": null,
- "module": "flask/sansio",
- "defect_score": 1.35,
- "maintainability_score": 4.8,
- "performance_score": 10,
- "top_biomarkers": [
- {
- "id": "cb2c376ceb485261bac68091",
- "biomarker_type": "untested_hotspot",
- "severity": "high",
- "file_path": "src/flask/sansio/app.py",
- "function_name": null,
- "line_start": null,
- "line_end": null,
- "details": {
- "line_coverage_pct": null,
- "branch_coverage_pct": null,
- "dependents_count": 7,
- "commit_count_90d": 1,
- "has_test_file": false
- },
- "health_impact": 1.56,
- "reason": "Hotspot with no paired test file and no coverage data — 7 dependents",
- "status": "open",
- "suggestion": "Hot file with low/no coverage — add tests against the most-changed methods first.",
- "dimension": "defect",
- "symbol_id": null
- },
- {
- "id": "25e5ed47ef2620733ce4d61b",
- "biomarker_type": "function_hotspot",
- "severity": "high",
- "file_path": "src/flask/sansio/app.py",
- "function_name": "add_url_rule",
- "line_start": 605,
- "line_end": 661,
- "details": {
- "modification_count": 19,
- "repo_p80": 5,
- "ccn": 12,
- "max_nesting": 2
- },
- "health_impact": 1.18,
- "reason": "add_url_rule has been modified across 19 commits (repo p80=5) and carries CCN=12 / nesting=2",
- "status": "open",
- "suggestion": "Review and refactor according to the biomarker details.",
- "dimension": "defect",
- "symbol_id": null
- }
- ]
- },
- {
- "file_path": "src/flask/cli.py",
- "score": 2.05,
- "band": "at_risk",
- "max_ccn": 13,
- "max_nesting": 5,
- "nloc": 822,
- "duplication_pct": null,
- "has_test_file": true,
- "line_coverage_pct": null,
- "branch_coverage_pct": null,
- "module": "flask",
- "defect_score": 2.05,
- "maintainability_score": 3.6,
- "performance_score": 9.85,
- "top_biomarkers": [
- {
- "id": "3c7b89ff0c13fa0b1123901b",
- "biomarker_type": "nested_complexity",
- "severity": "high",
- "file_path": "src/flask/cli.py",
- "function_name": "convert",
- "line_start": 791,
- "line_end": 825,
- "details": {
- "max_nesting": 5,
- "ccn": 6,
- "cognitive": 21
- },
- "health_impact": 0.605,
- "reason": "convert nests 5 levels deep",
- "status": "open",
- "suggestion": "Flatten nested control flow with early returns or guard clauses.",
- "dimension": "defect",
- "symbol_id": null
- },
- {
- "id": "d9c8ad9cb0af754e7a5a0a54",
- "biomarker_type": "nested_complexity",
- "severity": "high",
- "file_path": "src/flask/cli.py",
- "function_name": "find_best_app",
- "line_start": 41,
- "line_end": 91,
- "details": {
- "max_nesting": 5,
- "ccn": 10,
- "cognitive": 25
- },
- "health_impact": 0.605,
- "reason": "find_best_app nests 5 levels deep",
- "status": "open",
- "suggestion": "Flatten nested control flow with early returns or guard clauses.",
- "dimension": "defect",
- "symbol_id": null
- }
- ]
- }
-]
diff --git a/packages/api-client/src/__fixtures__/hosted/health-findings.json b/packages/api-client/src/__fixtures__/hosted/health-findings.json
deleted file mode 100644
index 9dc411013..000000000
--- a/packages/api-client/src/__fixtures__/hosted/health-findings.json
+++ /dev/null
@@ -1,1022 +0,0 @@
-{
- "items": [
- {
- "id": "24ee1f24b481e78e25d7b1aa",
- "biomarker_type": "primitive_obsession",
- "severity": "medium",
- "file_path": "docs/conf.py",
- "function_name": "github_link",
- "line_start": 72,
- "line_end": 97,
- "details": {
- "param_count": 7
- },
- "health_impact": 0.35,
- "reason": "github_link takes 7 parameters",
- "status": "open",
- "suggestion": null,
- "dimension": "maintainability",
- "symbol_id": "docs/conf.py::github_link"
- },
- {
- "id": "7fc2bfb45bd876adac3926a2",
- "biomarker_type": "ownership_risk",
- "severity": "low",
- "file_path": "docs/conf.py",
- "function_name": null,
- "line_start": null,
- "line_end": null,
- "details": {
- "minor_contributors": 6,
- "top_owner_share": 0.771,
- "contributor_count": 8,
- "total_commits": 48,
- "small_team": true
- },
- "health_impact": 0.414,
- "reason": "6 minor contributors (each <5% of commits); top owner holds 77% (informational: small team, 1 active contributors in 90d)",
- "status": "open",
- "suggestion": null,
- "dimension": "defect",
- "symbol_id": null
- },
- {
- "id": "09d0b47644642dd7b41fd9c1",
- "biomarker_type": "nested_complexity",
- "severity": "medium",
- "file_path": "examples/tutorial/flaskr/auth.py",
- "function_name": "register",
- "line_start": 47,
- "line_end": 81,
- "details": {
- "max_nesting": 4,
- "ccn": 6,
- "cognitive": 15
- },
- "health_impact": 0.938,
- "reason": "register nests 4 levels deep",
- "status": "open",
- "suggestion": null,
- "dimension": "defect",
- "symbol_id": "examples/tutorial/flaskr/auth.py::register"
- },
- {
- "id": "845765e86a8dc67f7be0f099",
- "biomarker_type": "dry_violation",
- "severity": "medium",
- "file_path": "examples/tutorial/flaskr/blog.py",
- "function_name": null,
- "line_start": 64,
- "line_end": 77,
- "details": {
- "duplication_pct": 28,
- "clone_pair_count": 1,
- "worst_clone_lines": 14,
- "worst_clone_partner": "examples/tutorial/flaskr/blog.py",
- "worst_clone_co_change": 0
- },
- "health_impact": 0.35,
- "reason": "28% of file duplicated; worst clone shares 14 lines with examples/tutorial/flaskr/blog.py",
- "status": "open",
- "suggestion": null,
- "dimension": "maintainability",
- "symbol_id": "examples/tutorial/flaskr/blog.py::create"
- },
- {
- "id": "a254a623ca40c0367121f788",
- "biomarker_type": "dry_violation",
- "severity": "medium",
- "file_path": "src/flask/__init__.py",
- "function_name": null,
- "line_start": 1,
- "line_end": 38,
- "details": {
- "duplication_pct": 100,
- "clone_pair_count": 1,
- "worst_clone_lines": 38,
- "worst_clone_partner": "src/flask/__init__.py",
- "worst_clone_co_change": 0
- },
- "health_impact": 0.35,
- "reason": "100% of file duplicated; worst clone shares 38 lines with src/flask/__init__.py",
- "status": "open",
- "suggestion": null,
- "dimension": "maintainability",
- "symbol_id": null
- },
- {
- "id": "8510993cad8a38502173828e",
- "biomarker_type": "ownership_risk",
- "severity": "low",
- "file_path": "src/flask/__init__.py",
- "function_name": null,
- "line_start": null,
- "line_end": null,
- "details": {
- "minor_contributors": 6,
- "top_owner_share": 0.9,
- "contributor_count": 7,
- "total_commits": 70,
- "small_team": true
- },
- "health_impact": 0.414,
- "reason": "6 minor contributors (each <5% of commits); top owner holds 90% (informational: small team, 1 active contributors in 90d)",
- "status": "open",
- "suggestion": null,
- "dimension": "defect",
- "symbol_id": null
- },
- {
- "id": "3d05bc5d79a01696d298014f",
- "biomarker_type": "low_cohesion",
- "severity": "medium",
- "file_path": "src/flask/cli.py",
- "function_name": "FlaskGroup",
- "line_start": 531,
- "line_end": 688,
- "details": {
- "class_name": "FlaskGroup",
- "lcom4": 2,
- "method_count": 6,
- "field_count": 8
- },
- "health_impact": 0.132,
- "reason": "FlaskGroup has low cohesion (LCOM4=2): its 6 methods split into 2 groups that share no fields or calls",
- "status": "open",
- "suggestion": null,
- "dimension": "maintainability",
- "symbol_id": "src/flask/cli.py::FlaskGroup"
- },
- {
- "id": "3c7b89ff0c13fa0b1123901b",
- "biomarker_type": "nested_complexity",
- "severity": "high",
- "file_path": "src/flask/cli.py",
- "function_name": "convert",
- "line_start": 791,
- "line_end": 825,
- "details": {
- "max_nesting": 5,
- "ccn": 6,
- "cognitive": 21
- },
- "health_impact": 0.605,
- "reason": "convert nests 5 levels deep",
- "status": "open",
- "suggestion": null,
- "dimension": "defect",
- "symbol_id": "src/flask/cli.py::CertParamType::convert"
- },
- {
- "id": "6b2d945db56c1c1a84bc1b61",
- "biomarker_type": "nested_complexity",
- "severity": "medium",
- "file_path": "src/flask/cli.py",
- "function_name": "load_app",
- "line_start": 333,
- "line_end": 372,
- "details": {
- "max_nesting": 4,
- "ccn": 8,
- "cognitive": 13
- },
- "health_impact": 0.353,
- "reason": "load_app nests 4 levels deep",
- "status": "open",
- "suggestion": null,
- "dimension": "defect",
- "symbol_id": "src/flask/cli.py::ScriptInfo::load_app"
- },
- {
- "id": "14513497430140aabebfc2fe",
- "biomarker_type": "nested_complexity",
- "severity": "medium",
- "file_path": "src/flask/cli.py",
- "function_name": "find_app_by_string",
- "line_start": 120,
- "line_end": 197,
- "details": {
- "max_nesting": 4,
- "ccn": 11,
- "cognitive": 30
- },
- "health_impact": 0.353,
- "reason": "find_app_by_string nests 4 levels deep",
- "status": "open",
- "suggestion": null,
- "dimension": "defect",
- "symbol_id": "src/flask/cli.py::find_app_by_string"
- },
- {
- "id": "d9c8ad9cb0af754e7a5a0a54",
- "biomarker_type": "nested_complexity",
- "severity": "high",
- "file_path": "src/flask/cli.py",
- "function_name": "find_best_app",
- "line_start": 41,
- "line_end": 91,
- "details": {
- "max_nesting": 5,
- "ccn": 10,
- "cognitive": 25
- },
- "health_impact": 0.605,
- "reason": "find_best_app nests 5 levels deep",
- "status": "open",
- "suggestion": null,
- "dimension": "defect",
- "symbol_id": "src/flask/cli.py::find_best_app"
- },
- {
- "id": "d5bc5211e56aca8f359d5826",
- "biomarker_type": "complex_method",
- "severity": "medium",
- "file_path": "src/flask/cli.py",
- "function_name": "routes_command",
- "line_start": 1061,
- "line_end": 1107,
- "details": {
- "ccn": 13,
- "cognitive": 18,
- "nloc": 35
- },
- "health_impact": 0.237,
- "reason": "routes_command has cyclomatic complexity 13",
- "status": "open",
- "suggestion": null,
- "dimension": "defect",
- "symbol_id": "src/flask/cli.py::routes_command"
- },
- {
- "id": "cbb603900f1a645cb7015dca",
- "biomarker_type": "complex_method",
- "severity": "medium",
- "file_path": "src/flask/cli.py",
- "function_name": "_validate_key",
- "line_start": 828,
- "line_end": 864,
- "details": {
- "ccn": 9,
- "cognitive": 14,
- "nloc": 29
- },
- "health_impact": 0.237,
- "reason": "_validate_key has cyclomatic complexity 9",
- "status": "open",
- "suggestion": null,
- "dimension": "defect",
- "symbol_id": "src/flask/cli.py::_validate_key"
- },
- {
- "id": "ca167abaa1b0f1c1158ea66b",
- "biomarker_type": "complex_method",
- "severity": "medium",
- "file_path": "src/flask/cli.py",
- "function_name": "load_dotenv",
- "line_start": 698,
- "line_end": 763,
- "details": {
- "ccn": 13,
- "cognitive": 20,
- "nloc": 47
- },
- "health_impact": 0.237,
- "reason": "load_dotenv has cyclomatic complexity 13",
- "status": "open",
- "suggestion": null,
- "dimension": "defect",
- "symbol_id": "src/flask/cli.py::load_dotenv"
- },
- {
- "id": "57ab482435ea9ed4a56a87bc",
- "biomarker_type": "complex_method",
- "severity": "medium",
- "file_path": "src/flask/cli.py",
- "function_name": "find_app_by_string",
- "line_start": 120,
- "line_end": 197,
- "details": {
- "ccn": 11,
- "cognitive": 30,
- "nloc": 68
- },
- "health_impact": 0.237,
- "reason": "find_app_by_string has cyclomatic complexity 11",
- "status": "open",
- "suggestion": null,
- "dimension": "defect",
- "symbol_id": "src/flask/cli.py::find_app_by_string"
- },
- {
- "id": "f22e456d7508251a6d18b2e9",
- "biomarker_type": "complex_method",
- "severity": "medium",
- "file_path": "src/flask/cli.py",
- "function_name": "find_best_app",
- "line_start": 41,
- "line_end": 91,
- "details": {
- "ccn": 10,
- "cognitive": 25,
- "nloc": 41
- },
- "health_impact": 0.237,
- "reason": "find_best_app has cyclomatic complexity 10",
- "status": "open",
- "suggestion": null,
- "dimension": "defect",
- "symbol_id": "src/flask/cli.py::find_best_app"
- },
- {
- "id": "7206560799f1a29b8bd7c4ac",
- "biomarker_type": "bumpy_road",
- "severity": "low",
- "file_path": "src/flask/cli.py",
- "function_name": "routes_command",
- "line_start": 1061,
- "line_end": 1107,
- "details": {
- "bumps": 3,
- "ccn": 13,
- "max_nesting": 3
- },
- "health_impact": 0.056,
- "reason": "routes_command has 3 nested blocks at the same level (bumpy road)",
- "status": "open",
- "suggestion": null,
- "dimension": "defect",
- "symbol_id": "src/flask/cli.py::routes_command"
- },
- {
- "id": "913c5f0126bcd903c916922e",
- "biomarker_type": "bumpy_road",
- "severity": "low",
- "file_path": "src/flask/cli.py",
- "function_name": "load_dotenv",
- "line_start": 698,
- "line_end": 763,
- "details": {
- "bumps": 3,
- "ccn": 13,
- "max_nesting": 3
- },
- "health_impact": 0.056,
- "reason": "load_dotenv has 3 nested blocks at the same level (bumpy road)",
- "status": "open",
- "suggestion": null,
- "dimension": "defect",
- "symbol_id": "src/flask/cli.py::load_dotenv"
- },
- {
- "id": "0c5715dc8398bb9ecd57b830",
- "biomarker_type": "bumpy_road",
- "severity": "medium",
- "file_path": "src/flask/cli.py",
- "function_name": "find_app_by_string",
- "line_start": 120,
- "line_end": 197,
- "details": {
- "bumps": 4,
- "ccn": 11,
- "max_nesting": 4
- },
- "health_impact": 0.132,
- "reason": "find_app_by_string has 4 nested blocks at the same level (bumpy road)",
- "status": "open",
- "suggestion": null,
- "dimension": "defect",
- "symbol_id": "src/flask/cli.py::find_app_by_string"
- },
- {
- "id": "cc5c719dea8b6a80d1476727",
- "biomarker_type": "bumpy_road",
- "severity": "low",
- "file_path": "src/flask/cli.py",
- "function_name": "find_best_app",
- "line_start": 41,
- "line_end": 91,
- "details": {
- "bumps": 3,
- "ccn": 10,
- "max_nesting": 5
- },
- "health_impact": 0.056,
- "reason": "find_best_app has 3 nested blocks at the same level (bumpy road)",
- "status": "open",
- "suggestion": null,
- "dimension": "defect",
- "symbol_id": "src/flask/cli.py::find_best_app"
- },
- {
- "id": "dd0194f456cad899e68c5882",
- "biomarker_type": "large_method",
- "severity": "low",
- "file_path": "src/flask/cli.py",
- "function_name": "find_app_by_string",
- "line_start": 120,
- "line_end": 197,
- "details": {
- "nloc": 68,
- "ccn": 11
- },
- "health_impact": 0.105,
- "reason": "find_app_by_string is 68 lines long",
- "status": "open",
- "suggestion": null,
- "dimension": "defect",
- "symbol_id": "src/flask/cli.py::find_app_by_string"
- },
- {
- "id": "35e3b26a20e7b8469cf29305",
- "biomarker_type": "primitive_obsession",
- "severity": "high",
- "file_path": "src/flask/cli.py",
- "function_name": "run_command",
- "line_start": 935,
- "line_end": 993,
- "details": {
- "param_count": 9
- },
- "health_impact": 0.168,
- "reason": "run_command takes 9 parameters",
- "status": "open",
- "suggestion": null,
- "dimension": "maintainability",
- "symbol_id": "src/flask/cli.py::run_command"
- },
- {
- "id": "692f1eafa18fac253c10a7cd",
- "biomarker_type": "primitive_obsession",
- "severity": "low",
- "file_path": "src/flask/cli.py",
- "function_name": "make_context",
- "line_start": 657,
- "line_end": 676,
- "details": {
- "param_count": 5
- },
- "health_impact": 0.042,
- "reason": "make_context takes 5 parameters",
- "status": "open",
- "suggestion": null,
- "dimension": "maintainability",
- "symbol_id": "src/flask/cli.py::FlaskGroup::make_context"
- },
- {
- "id": "928db1374c4f29d5737fac2d",
- "biomarker_type": "complex_conditional",
- "severity": "low",
- "file_path": "src/flask/cli.py",
- "function_name": "parse_args",
- "line_start": 679,
- "line_end": 679,
- "details": {
- "operator_count": 3,
- "enclosing_construct": "if"
- },
- "health_impact": 0.15,
- "reason": "if condition combines 3 boolean operators",
- "status": "open",
- "suggestion": null,
- "dimension": "defect",
- "symbol_id": "src/flask/cli.py::FlaskGroup::parse_args"
- },
- {
- "id": "6def7c58d9285973cbd6f39d",
- "biomarker_type": "function_hotspot",
- "severity": "medium",
- "file_path": "src/flask/cli.py",
- "function_name": "routes_command",
- "line_start": 1061,
- "line_end": 1107,
- "details": {
- "modification_count": 6,
- "repo_p80": 5,
- "ccn": 13,
- "max_nesting": 3
- },
- "health_impact": 0.29,
- "reason": "routes_command has been modified across 6 commits (repo p80=5) and carries CCN=13 / nesting=3",
- "status": "open",
- "suggestion": null,
- "dimension": "defect",
- "symbol_id": "src/flask/cli.py::routes_command"
- },
- {
- "id": "59d987fdc3c5b86b84f15d0f",
- "biomarker_type": "function_hotspot",
- "severity": "high",
- "file_path": "src/flask/cli.py",
- "function_name": "shell_command",
- "line_start": 1001,
- "line_end": 1045,
- "details": {
- "modification_count": 13,
- "repo_p80": 5,
- "ccn": 5,
- "max_nesting": 3
- },
- "health_impact": 0.497,
- "reason": "shell_command has been modified across 13 commits (repo p80=5) and carries CCN=5 / nesting=3",
- "status": "open",
- "suggestion": null,
- "dimension": "defect",
- "symbol_id": "src/flask/cli.py::shell_command"
- },
- {
- "id": "b3c8a05d6fcfdb41ae13cefb",
- "biomarker_type": "function_hotspot",
- "severity": "high",
- "file_path": "src/flask/cli.py",
- "function_name": "run_command",
- "line_start": 935,
- "line_end": 993,
- "details": {
- "modification_count": 11,
- "repo_p80": 5,
- "ccn": 5,
- "max_nesting": 3
- },
- "health_impact": 0.497,
- "reason": "run_command has been modified across 11 commits (repo p80=5) and carries CCN=5 / nesting=3",
- "status": "open",
- "suggestion": null,
- "dimension": "defect",
- "symbol_id": "src/flask/cli.py::run_command"
- },
- {
- "id": "e1908844bfa38cece9505c6f",
- "biomarker_type": "function_hotspot",
- "severity": "medium",
- "file_path": "src/flask/cli.py",
- "function_name": "convert",
- "line_start": 791,
- "line_end": 825,
- "details": {
- "modification_count": 9,
- "repo_p80": 5,
- "ccn": 6,
- "max_nesting": 5
- },
- "health_impact": 0.29,
- "reason": "convert has been modified across 9 commits (repo p80=5) and carries CCN=6 / nesting=5",
- "status": "open",
- "suggestion": null,
- "dimension": "defect",
- "symbol_id": "src/flask/cli.py::CertParamType::convert"
- },
- {
- "id": "58266b29c997afce37748eda",
- "biomarker_type": "function_hotspot",
- "severity": "medium",
- "file_path": "src/flask/cli.py",
- "function_name": "load_dotenv",
- "line_start": 698,
- "line_end": 763,
- "details": {
- "modification_count": 9,
- "repo_p80": 5,
- "ccn": 13,
- "max_nesting": 3
- },
- "health_impact": 0.29,
- "reason": "load_dotenv has been modified across 9 commits (repo p80=5) and carries CCN=13 / nesting=3",
- "status": "open",
- "suggestion": null,
- "dimension": "defect",
- "symbol_id": "src/flask/cli.py::load_dotenv"
- },
- {
- "id": "f0ae5435d4f75d89f63cfa86",
- "biomarker_type": "function_hotspot",
- "severity": "high",
- "file_path": "src/flask/cli.py",
- "function_name": "load_app",
- "line_start": 333,
- "line_end": 372,
- "details": {
- "modification_count": 15,
- "repo_p80": 5,
- "ccn": 8,
- "max_nesting": 4
- },
- "health_impact": 0.497,
- "reason": "load_app has been modified across 15 commits (repo p80=5) and carries CCN=8 / nesting=4",
- "status": "open",
- "suggestion": null,
- "dimension": "defect",
- "symbol_id": "src/flask/cli.py::ScriptInfo::load_app"
- },
- {
- "id": "aee5b1828c3883a30621c4de",
- "biomarker_type": "function_hotspot",
- "severity": "high",
- "file_path": "src/flask/cli.py",
- "function_name": "find_app_by_string",
- "line_start": 120,
- "line_end": 197,
- "details": {
- "modification_count": 13,
- "repo_p80": 5,
- "ccn": 11,
- "max_nesting": 4
- },
- "health_impact": 0.497,
- "reason": "find_app_by_string has been modified across 13 commits (repo p80=5) and carries CCN=11 / nesting=4",
- "status": "open",
- "suggestion": null,
- "dimension": "defect",
- "symbol_id": "src/flask/cli.py::find_app_by_string"
- },
- {
- "id": "6ac160cd46a9479d6d2263b1",
- "biomarker_type": "function_hotspot",
- "severity": "high",
- "file_path": "src/flask/cli.py",
- "function_name": "find_best_app",
- "line_start": 41,
- "line_end": 91,
- "details": {
- "modification_count": 17,
- "repo_p80": 5,
- "ccn": 10,
- "max_nesting": 5
- },
- "health_impact": 0.497,
- "reason": "find_best_app has been modified across 17 commits (repo p80=5) and carries CCN=10 / nesting=5",
- "status": "open",
- "suggestion": null,
- "dimension": "defect",
- "symbol_id": "src/flask/cli.py::find_best_app"
- },
- {
- "id": "fb1070635166396549df3d9d",
- "biomarker_type": "ownership_risk",
- "severity": "low",
- "file_path": "src/flask/cli.py",
- "function_name": null,
- "line_start": null,
- "line_end": null,
- "details": {
- "minor_contributors": 16,
- "top_owner_share": 0.697,
- "contributor_count": 18,
- "total_commits": 66,
- "small_team": true
- },
- "health_impact": 0.148,
- "reason": "16 minor contributors (each <5% of commits); top owner holds 70% (informational: small team, 1 active contributors in 90d)",
- "status": "open",
- "suggestion": null,
- "dimension": "defect",
- "symbol_id": null
- },
- {
- "id": "19efd878bb50fe44398161e7",
- "biomarker_type": "error_handling",
- "severity": "low",
- "file_path": "src/flask/cli.py",
- "function_name": null,
- "line_start": 650,
- "line_end": 650,
- "details": {
- "kind": "bare_except"
- },
- "health_impact": 0.15,
- "reason": "catch-all except hides every error, including KeyboardInterrupt",
- "status": "open",
- "suggestion": null,
- "dimension": "maintainability",
- "symbol_id": "src/flask/cli.py::FlaskGroup::list_commands"
- },
- {
- "id": "db511e524f8430078dc806c9",
- "biomarker_type": "error_handling",
- "severity": "low",
- "file_path": "src/flask/cli.py",
- "function_name": null,
- "line_start": 1036,
- "line_end": 1036,
- "details": {
- "kind": "swallowed_catch"
- },
- "health_impact": 0.15,
- "reason": "caught exception is swallowed without any handling",
- "status": "open",
- "suggestion": null,
- "dimension": "maintainability",
- "symbol_id": "src/flask/cli.py::shell_command"
- },
- {
- "id": "1c5ab929fed77ec9ae5d3bf3",
- "biomarker_type": "error_handling",
- "severity": "low",
- "file_path": "src/flask/cli.py",
- "function_name": null,
- "line_start": 1098,
- "line_end": 1098,
- "details": {
- "kind": "swallowed_catch"
- },
- "health_impact": 0.15,
- "reason": "caught exception is swallowed without any handling",
- "status": "open",
- "suggestion": null,
- "dimension": "maintainability",
- "symbol_id": "src/flask/cli.py::routes_command"
- },
- {
- "id": "21e7656ae601236104f81d2e",
- "biomarker_type": "hot_path_sync_io",
- "severity": "low",
- "file_path": "src/flask/cli.py",
- "function_name": "shell_command",
- "line_start": 1022,
- "line_end": 1022,
- "details": {
- "boundary_kind": "filesystem"
- },
- "health_impact": 0,
- "reason": "a blocking filesystem call runs on a hot, request-reachable path; its latency is paid on every call through this function",
- "status": "open",
- "suggestion": null,
- "dimension": "performance",
- "symbol_id": "src/flask/cli.py::shell_command"
- },
- {
- "id": "866b5edd940c2fd3c736feb8",
- "biomarker_type": "dry_violation",
- "severity": "low",
- "file_path": "src/flask/globals.py",
- "function_name": null,
- "line_start": 18,
- "line_end": 28,
- "details": {
- "duplication_pct": 22.41,
- "clone_pair_count": 1,
- "worst_clone_lines": 11,
- "worst_clone_partner": "src/flask/globals.py",
- "worst_clone_co_change": 0
- },
- "health_impact": 0.15,
- "reason": "22% of file duplicated; worst clone shares 11 lines with src/flask/globals.py",
- "status": "open",
- "suggestion": null,
- "dimension": "maintainability",
- "symbol_id": "src/flask/globals.py::ProxyMixin::_get_current_object"
- },
- {
- "id": "dd3381c1030aed17697543ea",
- "biomarker_type": "complex_method",
- "severity": "medium",
- "file_path": "src/flask/helpers.py",
- "function_name": "get_root_path",
- "line_start": 587,
- "line_end": 641,
- "details": {
- "ccn": 9,
- "cognitive": 12,
- "nloc": 45
- },
- "health_impact": 0.821,
- "reason": "get_root_path has cyclomatic complexity 9",
- "status": "open",
- "suggestion": null,
- "dimension": "defect",
- "symbol_id": "src/flask/helpers.py::get_root_path"
- },
- {
- "id": "0da42a3887baa307c4485598",
- "biomarker_type": "primitive_obsession",
- "severity": "medium",
- "file_path": "src/flask/helpers.py",
- "function_name": "send_file",
- "line_start": 417,
- "line_end": 540,
- "details": {
- "param_count": 8
- },
- "health_impact": 0.339,
- "reason": "send_file takes 8 parameters",
- "status": "open",
- "suggestion": null,
- "dimension": "maintainability",
- "symbol_id": "src/flask/helpers.py::send_file"
- },
- {
- "id": "1894a1e4e5d886fb52cbcbcf",
- "biomarker_type": "primitive_obsession",
- "severity": "medium",
- "file_path": "src/flask/helpers.py",
- "function_name": "url_for",
- "line_start": 200,
- "line_end": 251,
- "details": {
- "param_count": 7
- },
- "health_impact": 0.339,
- "reason": "url_for takes 7 parameters",
- "status": "open",
- "suggestion": null,
- "dimension": "maintainability",
- "symbol_id": "src/flask/helpers.py::url_for"
- },
- {
- "id": "818bb7c32b8a0ac81c3afe7d",
- "biomarker_type": "ownership_risk",
- "severity": "low",
- "file_path": "src/flask/helpers.py",
- "function_name": null,
- "line_start": null,
- "line_end": null,
- "details": {
- "minor_contributors": 20,
- "top_owner_share": 0.636,
- "contributor_count": 22,
- "total_commits": 88,
- "small_team": true
- },
- "health_impact": 0.414,
- "reason": "20 minor contributors (each <5% of commits); top owner holds 64% (informational: small team, 1 active contributors in 90d)",
- "status": "open",
- "suggestion": null,
- "dimension": "defect",
- "symbol_id": null
- },
- {
- "id": "e3e3a4f918437a70cfea06c5",
- "biomarker_type": "complex_method",
- "severity": "medium",
- "file_path": "src/flask/debughelpers.py",
- "function_name": "explain_template_loading_attempts",
- "line_start": 124,
- "line_end": 179,
- "details": {
- "ccn": 13,
- "cognitive": 18,
- "nloc": 37
- },
- "health_impact": 0.847,
- "reason": "explain_template_loading_attempts has cyclomatic complexity 13",
- "status": "open",
- "suggestion": null,
- "dimension": "defect",
- "symbol_id": "src/flask/debughelpers.py::explain_template_loading_attempts"
- },
- {
- "id": "fcb77b4c8e501e308d016f2b",
- "biomarker_type": "function_hotspot",
- "severity": "medium",
- "file_path": "src/flask/debughelpers.py",
- "function_name": "explain_template_loading_attempts",
- "line_start": 124,
- "line_end": 179,
- "details": {
- "modification_count": 8,
- "repo_p80": 5,
- "ccn": 13,
- "max_nesting": 3
- },
- "health_impact": 0.812,
- "reason": "explain_template_loading_attempts has been modified across 8 commits (repo p80=5) and carries CCN=13 / nesting=3",
- "status": "open",
- "suggestion": null,
- "dimension": "defect",
- "symbol_id": "src/flask/debughelpers.py::explain_template_loading_attempts"
- },
- {
- "id": "ec30edc0a31e12eaa4c24baa",
- "biomarker_type": "function_hotspot",
- "severity": "medium",
- "file_path": "src/flask/debughelpers.py",
- "function_name": "_dump_loader_info",
- "line_start": 107,
- "line_end": 121,
- "details": {
- "modification_count": 6,
- "repo_p80": 5,
- "ccn": 7,
- "max_nesting": 3
- },
- "health_impact": 0.812,
- "reason": "_dump_loader_info has been modified across 6 commits (repo p80=5) and carries CCN=7 / nesting=3",
- "status": "open",
- "suggestion": null,
- "dimension": "defect",
- "symbol_id": "src/flask/debughelpers.py::_dump_loader_info"
- },
- {
- "id": "a268d5af746390e327d8c3e2",
- "biomarker_type": "brain_method",
- "severity": "high",
- "file_path": "src/flask/app.py",
- "function_name": "make_response",
- "line_start": 1224,
- "line_end": 1364,
- "details": {
- "ccn": 16,
- "nloc": 119,
- "max_nesting": 5,
- "dependents_count": 6,
- "centrality_floor": 5
- },
- "health_impact": 0.141,
- "reason": "Brain Method: make_response is 119 lines, CCN 16, in a file imported by 6 others",
- "status": "open",
- "suggestion": null,
- "dimension": "maintainability",
- "symbol_id": "src/flask/app.py::Flask::make_response"
- },
- {
- "id": "bce878892996951400e98fad",
- "biomarker_type": "brain_method",
- "severity": "medium",
- "file_path": "src/flask/app.py",
- "function_name": "url_for",
- "line_start": 1102,
- "line_end": 1222,
- "details": {
- "ccn": 13,
- "nloc": 94,
- "max_nesting": 3,
- "dependents_count": 6,
- "centrality_floor": 5
- },
- "health_impact": 0.082,
- "reason": "Brain Method: url_for is 94 lines, CCN 13, in a file imported by 6 others",
- "status": "open",
- "suggestion": null,
- "dimension": "maintainability",
- "symbol_id": "src/flask/app.py::Flask::url_for"
- },
- {
- "id": "5aba56e5bbdd42c6154c3f8b",
- "biomarker_type": "brain_method",
- "severity": "medium",
- "file_path": "src/flask/app.py",
- "function_name": "run",
- "line_start": 632,
- "line_end": 753,
- "details": {
- "ccn": 12,
- "nloc": 91,
- "max_nesting": 2,
- "dependents_count": 6,
- "centrality_floor": 5
- },
- "health_impact": 0.082,
- "reason": "Brain Method: run is 91 lines, CCN 12, in a file imported by 6 others",
- "status": "open",
- "suggestion": null,
- "dimension": "maintainability",
- "symbol_id": "src/flask/app.py::Flask::run"
- },
- {
- "id": "b947e6b2fbf89f86347697af",
- "biomarker_type": "low_cohesion",
- "severity": "critical",
- "file_path": "src/flask/app.py",
- "function_name": "Flask",
- "line_start": 109,
- "line_end": 1625,
- "details": {
- "class_name": "Flask",
- "lcom4": 6,
- "method_count": 35,
- "field_count": 36
- },
- "health_impact": 0.234,
- "reason": "Flask has low cohesion (LCOM4=6): its 35 methods split into 6 groups that share no fields or calls",
- "status": "open",
- "suggestion": null,
- "dimension": "maintainability",
- "symbol_id": "src/flask/app.py::Flask"
- },
- {
- "id": "352bff6fdeba1bb9c11a3be3",
- "biomarker_type": "god_class",
- "severity": "critical",
- "file_path": "src/flask/app.py",
- "function_name": "Flask",
- "line_start": 109,
- "line_end": 1625,
- "details": {
- "class_name": "Flask",
- "total_nloc": 1238,
- "method_count": 35,
- "max_method_ccn": 16
- },
- "health_impact": 0.53,
- "reason": "Flask is a god class: 1238 lines across 35 methods, including a brain method (max method CCN 16)",
- "status": "open",
- "suggestion": null,
- "dimension": "defect",
- "symbol_id": "src/flask/app.py::Flask"
- }
- ],
- "total": 209,
- "has_more": true,
- "next_offset": 50,
- "state": "ready",
- "reason": null
-}
diff --git a/packages/api-client/src/__fixtures__/hosted/health-overview.json b/packages/api-client/src/__fixtures__/hosted/health-overview.json
deleted file mode 100644
index f2bff2bf3..000000000
--- a/packages/api-client/src/__fixtures__/hosted/health-overview.json
+++ /dev/null
@@ -1,1707 +0,0 @@
-{
- "kpis": {
- "hotspot_health": 10,
- "average_health": 6.94,
- "worst_performer_path": "src/flask/app.py",
- "worst_performer_score": 1.07,
- "file_count": 108,
- "maintainability_average": 7.71,
- "performance_average": 9.96,
- "maintainability_findings": 73,
- "performance_findings": 4
- },
- "files": [
- {
- "file_path": "src/flask/app.py",
- "score": 1.07,
- "band": "at_risk",
- "max_ccn": 16,
- "max_nesting": 5,
- "nloc": 1235,
- "duplication_pct": 10.42,
- "has_test_file": false,
- "line_coverage_pct": null,
- "branch_coverage_pct": null,
- "module": "flask",
- "defect_score": 1.07,
- "maintainability_score": 3.1,
- "performance_score": 9.7,
- "top_biomarkers": [
- {
- "id": "1633695362c7ee2ec41d4144",
- "biomarker_type": "untested_hotspot",
- "severity": "high",
- "file_path": "src/flask/app.py",
- "function_name": null,
- "line_start": null,
- "line_end": null,
- "details": {
- "line_coverage_pct": null,
- "branch_coverage_pct": null,
- "dependents_count": 6,
- "commit_count_90d": 0,
- "has_test_file": false
- },
- "health_impact": 1.56,
- "reason": "Hotspot with no paired test file and no coverage data — 6 dependents",
- "status": "open",
- "suggestion": "Hot file with low/no coverage — add tests against the most-changed methods first.",
- "dimension": "defect",
- "symbol_id": null
- },
- {
- "id": "a636c1b680c14f66696424f2",
- "biomarker_type": "function_hotspot",
- "severity": "high",
- "file_path": "src/flask/app.py",
- "function_name": "make_response",
- "line_start": 1224,
- "line_end": 1364,
- "details": {
- "modification_count": 6,
- "repo_p80": 5,
- "ccn": 16,
- "max_nesting": 5
- },
- "health_impact": 1.392,
- "reason": "make_response has been modified across 6 commits (repo p80=5) and carries CCN=16 / nesting=5",
- "status": "open",
- "suggestion": "Review and refactor according to the biomarker details.",
- "dimension": "defect",
- "symbol_id": null
- }
- ]
- },
- {
- "file_path": "src/flask/sansio/app.py",
- "score": 1.35,
- "band": "at_risk",
- "max_ccn": 12,
- "max_nesting": 4,
- "nloc": 678,
- "duplication_pct": 14.3,
- "has_test_file": false,
- "line_coverage_pct": null,
- "branch_coverage_pct": null,
- "module": "flask/sansio",
- "defect_score": 1.35,
- "maintainability_score": 4.8,
- "performance_score": 10,
- "top_biomarkers": [
- {
- "id": "cb2c376ceb485261bac68091",
- "biomarker_type": "untested_hotspot",
- "severity": "high",
- "file_path": "src/flask/sansio/app.py",
- "function_name": null,
- "line_start": null,
- "line_end": null,
- "details": {
- "line_coverage_pct": null,
- "branch_coverage_pct": null,
- "dependents_count": 7,
- "commit_count_90d": 1,
- "has_test_file": false
- },
- "health_impact": 1.56,
- "reason": "Hotspot with no paired test file and no coverage data — 7 dependents",
- "status": "open",
- "suggestion": "Hot file with low/no coverage — add tests against the most-changed methods first.",
- "dimension": "defect",
- "symbol_id": null
- },
- {
- "id": "25e5ed47ef2620733ce4d61b",
- "biomarker_type": "function_hotspot",
- "severity": "high",
- "file_path": "src/flask/sansio/app.py",
- "function_name": "add_url_rule",
- "line_start": 605,
- "line_end": 661,
- "details": {
- "modification_count": 19,
- "repo_p80": 5,
- "ccn": 12,
- "max_nesting": 2
- },
- "health_impact": 1.18,
- "reason": "add_url_rule has been modified across 19 commits (repo p80=5) and carries CCN=12 / nesting=2",
- "status": "open",
- "suggestion": "Review and refactor according to the biomarker details.",
- "dimension": "defect",
- "symbol_id": null
- }
- ]
- },
- {
- "file_path": "src/flask/cli.py",
- "score": 2.05,
- "band": "at_risk",
- "max_ccn": 13,
- "max_nesting": 5,
- "nloc": 822,
- "duplication_pct": null,
- "has_test_file": true,
- "line_coverage_pct": null,
- "branch_coverage_pct": null,
- "module": "flask",
- "defect_score": 2.05,
- "maintainability_score": 3.6,
- "performance_score": 9.85,
- "top_biomarkers": [
- {
- "id": "3c7b89ff0c13fa0b1123901b",
- "biomarker_type": "nested_complexity",
- "severity": "high",
- "file_path": "src/flask/cli.py",
- "function_name": "convert",
- "line_start": 791,
- "line_end": 825,
- "details": {
- "max_nesting": 5,
- "ccn": 6,
- "cognitive": 21
- },
- "health_impact": 0.605,
- "reason": "convert nests 5 levels deep",
- "status": "open",
- "suggestion": "Flatten nested control flow with early returns or guard clauses.",
- "dimension": "defect",
- "symbol_id": null
- },
- {
- "id": "d9c8ad9cb0af754e7a5a0a54",
- "biomarker_type": "nested_complexity",
- "severity": "high",
- "file_path": "src/flask/cli.py",
- "function_name": "find_best_app",
- "line_start": 41,
- "line_end": 91,
- "details": {
- "max_nesting": 5,
- "ccn": 10,
- "cognitive": 25
- },
- "health_impact": 0.605,
- "reason": "find_best_app nests 5 levels deep",
- "status": "open",
- "suggestion": "Flatten nested control flow with early returns or guard clauses.",
- "dimension": "defect",
- "symbol_id": null
- }
- ]
- },
- {
- "file_path": "src/flask/sansio/blueprints.py",
- "score": 3.53,
- "band": "at_risk",
- "max_ccn": 22,
- "max_nesting": 3,
- "nloc": 557,
- "duplication_pct": 20.63,
- "has_test_file": true,
- "line_coverage_pct": null,
- "branch_coverage_pct": null,
- "module": "flask/sansio",
- "defect_score": 3.53,
- "maintainability_score": 5.4,
- "performance_score": 10,
- "top_biomarkers": [
- {
- "id": "c2d2eaab3a7919f76340c959",
- "biomarker_type": "function_hotspot",
- "severity": "critical",
- "file_path": "src/flask/sansio/blueprints.py",
- "function_name": "register",
- "line_start": 273,
- "line_end": 377,
- "details": {
- "modification_count": 23,
- "repo_p80": 5,
- "ccn": 22,
- "max_nesting": 3
- },
- "health_impact": 2.32,
- "reason": "register has been modified across 23 commits (repo p80=5) and carries CCN=22 / nesting=3",
- "status": "open",
- "suggestion": "Review and refactor according to the biomarker details.",
- "dimension": "defect",
- "symbol_id": null
- },
- {
- "id": "54354aebd028ccbd8c7730bc",
- "biomarker_type": "god_class",
- "severity": "critical",
- "file_path": "src/flask/sansio/blueprints.py",
- "function_name": "Blueprint",
- "line_start": 119,
- "line_end": 692,
- "details": {
- "class_name": "Blueprint",
- "total_nloc": 473,
- "method_count": 28,
- "max_method_ccn": 22
- },
- "health_impact": 1.657,
- "reason": "Blueprint is a god class: 473 lines across 28 methods, including a brain method (max method CCN 22)",
- "status": "open",
- "suggestion": "Review and refactor according to the biomarker details.",
- "dimension": "defect",
- "symbol_id": null
- }
- ]
- },
- {
- "file_path": "src/flask/config.py",
- "score": 5.15,
- "band": "needs_work",
- "max_ccn": 7,
- "max_nesting": 3,
- "nloc": 282,
- "duplication_pct": null,
- "has_test_file": true,
- "line_coverage_pct": null,
- "branch_coverage_pct": null,
- "module": "tests",
- "defect_score": 5.15,
- "maintainability_score": 6.7,
- "performance_score": 10,
- "top_biomarkers": [
- {
- "id": "6d907c7224823a792f775870",
- "biomarker_type": "function_hotspot",
- "severity": "high",
- "file_path": "src/flask/config.py",
- "function_name": "from_file",
- "line_start": 256,
- "line_end": 302,
- "details": {
- "modification_count": 12,
- "repo_p80": 5,
- "ccn": 5,
- "max_nesting": 3
- },
- "health_impact": 1.392,
- "reason": "from_file has been modified across 12 commits (repo p80=5) and carries CCN=5 / nesting=3",
- "status": "open",
- "suggestion": "Review and refactor according to the biomarker details.",
- "dimension": "defect",
- "symbol_id": null
- },
- {
- "id": "a526153466bab14f9dfa6193",
- "biomarker_type": "function_hotspot",
- "severity": "high",
- "file_path": "src/flask/config.py",
- "function_name": "from_pyfile",
- "line_start": 187,
- "line_end": 216,
- "details": {
- "modification_count": 10,
- "repo_p80": 5,
- "ccn": 4,
- "max_nesting": 3
- },
- "health_impact": 1.392,
- "reason": "from_pyfile has been modified across 10 commits (repo p80=5) and carries CCN=4 / nesting=3",
- "status": "open",
- "suggestion": "Review and refactor according to the biomarker details.",
- "dimension": "defect",
- "symbol_id": null
- }
- ]
- }
- ],
- "biomarkers": [
- {
- "id": "24ee1f24b481e78e25d7b1aa",
- "biomarker_type": "primitive_obsession",
- "severity": "medium",
- "file_path": "docs/conf.py",
- "function_name": "github_link",
- "line_start": 72,
- "line_end": 97,
- "details": {
- "param_count": 7
- },
- "health_impact": 0.35,
- "reason": "github_link takes 7 parameters",
- "status": "open",
- "suggestion": null,
- "dimension": "maintainability",
- "symbol_id": null
- },
- {
- "id": "7fc2bfb45bd876adac3926a2",
- "biomarker_type": "ownership_risk",
- "severity": "low",
- "file_path": "docs/conf.py",
- "function_name": null,
- "line_start": null,
- "line_end": null,
- "details": {
- "minor_contributors": 6,
- "top_owner_share": 0.771,
- "contributor_count": 8,
- "total_commits": 48,
- "small_team": true
- },
- "health_impact": 0.414,
- "reason": "6 minor contributors (each <5% of commits); top owner holds 77% (informational: small team, 1 active contributors in 90d)",
- "status": "open",
- "suggestion": null,
- "dimension": "defect",
- "symbol_id": null
- },
- {
- "id": "09d0b47644642dd7b41fd9c1",
- "biomarker_type": "nested_complexity",
- "severity": "medium",
- "file_path": "examples/tutorial/flaskr/auth.py",
- "function_name": "register",
- "line_start": 47,
- "line_end": 81,
- "details": {
- "max_nesting": 4,
- "ccn": 6,
- "cognitive": 15
- },
- "health_impact": 0.938,
- "reason": "register nests 4 levels deep",
- "status": "open",
- "suggestion": null,
- "dimension": "defect",
- "symbol_id": null
- },
- {
- "id": "845765e86a8dc67f7be0f099",
- "biomarker_type": "dry_violation",
- "severity": "medium",
- "file_path": "examples/tutorial/flaskr/blog.py",
- "function_name": null,
- "line_start": 64,
- "line_end": 77,
- "details": {
- "duplication_pct": 28,
- "clone_pair_count": 1,
- "worst_clone_lines": 14,
- "worst_clone_partner": "examples/tutorial/flaskr/blog.py",
- "worst_clone_co_change": 0
- },
- "health_impact": 0.35,
- "reason": "28% of file duplicated; worst clone shares 14 lines with examples/tutorial/flaskr/blog.py",
- "status": "open",
- "suggestion": null,
- "dimension": "maintainability",
- "symbol_id": null
- },
- {
- "id": "a254a623ca40c0367121f788",
- "biomarker_type": "dry_violation",
- "severity": "medium",
- "file_path": "src/flask/__init__.py",
- "function_name": null,
- "line_start": 1,
- "line_end": 38,
- "details": {
- "duplication_pct": 100,
- "clone_pair_count": 1,
- "worst_clone_lines": 38,
- "worst_clone_partner": "src/flask/__init__.py",
- "worst_clone_co_change": 0
- },
- "health_impact": 0.35,
- "reason": "100% of file duplicated; worst clone shares 38 lines with src/flask/__init__.py",
- "status": "open",
- "suggestion": null,
- "dimension": "maintainability",
- "symbol_id": null
- },
- {
- "id": "8510993cad8a38502173828e",
- "biomarker_type": "ownership_risk",
- "severity": "low",
- "file_path": "src/flask/__init__.py",
- "function_name": null,
- "line_start": null,
- "line_end": null,
- "details": {
- "minor_contributors": 6,
- "top_owner_share": 0.9,
- "contributor_count": 7,
- "total_commits": 70,
- "small_team": true
- },
- "health_impact": 0.414,
- "reason": "6 minor contributors (each <5% of commits); top owner holds 90% (informational: small team, 1 active contributors in 90d)",
- "status": "open",
- "suggestion": null,
- "dimension": "defect",
- "symbol_id": null
- },
- {
- "id": "3d05bc5d79a01696d298014f",
- "biomarker_type": "low_cohesion",
- "severity": "medium",
- "file_path": "src/flask/cli.py",
- "function_name": "FlaskGroup",
- "line_start": 531,
- "line_end": 688,
- "details": {
- "class_name": "FlaskGroup",
- "lcom4": 2,
- "method_count": 6,
- "field_count": 8
- },
- "health_impact": 0.132,
- "reason": "FlaskGroup has low cohesion (LCOM4=2): its 6 methods split into 2 groups that share no fields or calls",
- "status": "open",
- "suggestion": null,
- "dimension": "maintainability",
- "symbol_id": null
- },
- {
- "id": "3c7b89ff0c13fa0b1123901b",
- "biomarker_type": "nested_complexity",
- "severity": "high",
- "file_path": "src/flask/cli.py",
- "function_name": "convert",
- "line_start": 791,
- "line_end": 825,
- "details": {
- "max_nesting": 5,
- "ccn": 6,
- "cognitive": 21
- },
- "health_impact": 0.605,
- "reason": "convert nests 5 levels deep",
- "status": "open",
- "suggestion": null,
- "dimension": "defect",
- "symbol_id": null
- },
- {
- "id": "6b2d945db56c1c1a84bc1b61",
- "biomarker_type": "nested_complexity",
- "severity": "medium",
- "file_path": "src/flask/cli.py",
- "function_name": "load_app",
- "line_start": 333,
- "line_end": 372,
- "details": {
- "max_nesting": 4,
- "ccn": 8,
- "cognitive": 13
- },
- "health_impact": 0.353,
- "reason": "load_app nests 4 levels deep",
- "status": "open",
- "suggestion": null,
- "dimension": "defect",
- "symbol_id": null
- },
- {
- "id": "14513497430140aabebfc2fe",
- "biomarker_type": "nested_complexity",
- "severity": "medium",
- "file_path": "src/flask/cli.py",
- "function_name": "find_app_by_string",
- "line_start": 120,
- "line_end": 197,
- "details": {
- "max_nesting": 4,
- "ccn": 11,
- "cognitive": 30
- },
- "health_impact": 0.353,
- "reason": "find_app_by_string nests 4 levels deep",
- "status": "open",
- "suggestion": null,
- "dimension": "defect",
- "symbol_id": null
- },
- {
- "id": "d9c8ad9cb0af754e7a5a0a54",
- "biomarker_type": "nested_complexity",
- "severity": "high",
- "file_path": "src/flask/cli.py",
- "function_name": "find_best_app",
- "line_start": 41,
- "line_end": 91,
- "details": {
- "max_nesting": 5,
- "ccn": 10,
- "cognitive": 25
- },
- "health_impact": 0.605,
- "reason": "find_best_app nests 5 levels deep",
- "status": "open",
- "suggestion": null,
- "dimension": "defect",
- "symbol_id": null
- },
- {
- "id": "d5bc5211e56aca8f359d5826",
- "biomarker_type": "complex_method",
- "severity": "medium",
- "file_path": "src/flask/cli.py",
- "function_name": "routes_command",
- "line_start": 1061,
- "line_end": 1107,
- "details": {
- "ccn": 13,
- "cognitive": 18,
- "nloc": 35
- },
- "health_impact": 0.237,
- "reason": "routes_command has cyclomatic complexity 13",
- "status": "open",
- "suggestion": null,
- "dimension": "defect",
- "symbol_id": null
- },
- {
- "id": "cbb603900f1a645cb7015dca",
- "biomarker_type": "complex_method",
- "severity": "medium",
- "file_path": "src/flask/cli.py",
- "function_name": "_validate_key",
- "line_start": 828,
- "line_end": 864,
- "details": {
- "ccn": 9,
- "cognitive": 14,
- "nloc": 29
- },
- "health_impact": 0.237,
- "reason": "_validate_key has cyclomatic complexity 9",
- "status": "open",
- "suggestion": null,
- "dimension": "defect",
- "symbol_id": null
- },
- {
- "id": "ca167abaa1b0f1c1158ea66b",
- "biomarker_type": "complex_method",
- "severity": "medium",
- "file_path": "src/flask/cli.py",
- "function_name": "load_dotenv",
- "line_start": 698,
- "line_end": 763,
- "details": {
- "ccn": 13,
- "cognitive": 20,
- "nloc": 47
- },
- "health_impact": 0.237,
- "reason": "load_dotenv has cyclomatic complexity 13",
- "status": "open",
- "suggestion": null,
- "dimension": "defect",
- "symbol_id": null
- },
- {
- "id": "57ab482435ea9ed4a56a87bc",
- "biomarker_type": "complex_method",
- "severity": "medium",
- "file_path": "src/flask/cli.py",
- "function_name": "find_app_by_string",
- "line_start": 120,
- "line_end": 197,
- "details": {
- "ccn": 11,
- "cognitive": 30,
- "nloc": 68
- },
- "health_impact": 0.237,
- "reason": "find_app_by_string has cyclomatic complexity 11",
- "status": "open",
- "suggestion": null,
- "dimension": "defect",
- "symbol_id": null
- },
- {
- "id": "f22e456d7508251a6d18b2e9",
- "biomarker_type": "complex_method",
- "severity": "medium",
- "file_path": "src/flask/cli.py",
- "function_name": "find_best_app",
- "line_start": 41,
- "line_end": 91,
- "details": {
- "ccn": 10,
- "cognitive": 25,
- "nloc": 41
- },
- "health_impact": 0.237,
- "reason": "find_best_app has cyclomatic complexity 10",
- "status": "open",
- "suggestion": null,
- "dimension": "defect",
- "symbol_id": null
- },
- {
- "id": "7206560799f1a29b8bd7c4ac",
- "biomarker_type": "bumpy_road",
- "severity": "low",
- "file_path": "src/flask/cli.py",
- "function_name": "routes_command",
- "line_start": 1061,
- "line_end": 1107,
- "details": {
- "bumps": 3,
- "ccn": 13,
- "max_nesting": 3
- },
- "health_impact": 0.056,
- "reason": "routes_command has 3 nested blocks at the same level (bumpy road)",
- "status": "open",
- "suggestion": null,
- "dimension": "defect",
- "symbol_id": null
- },
- {
- "id": "913c5f0126bcd903c916922e",
- "biomarker_type": "bumpy_road",
- "severity": "low",
- "file_path": "src/flask/cli.py",
- "function_name": "load_dotenv",
- "line_start": 698,
- "line_end": 763,
- "details": {
- "bumps": 3,
- "ccn": 13,
- "max_nesting": 3
- },
- "health_impact": 0.056,
- "reason": "load_dotenv has 3 nested blocks at the same level (bumpy road)",
- "status": "open",
- "suggestion": null,
- "dimension": "defect",
- "symbol_id": null
- },
- {
- "id": "0c5715dc8398bb9ecd57b830",
- "biomarker_type": "bumpy_road",
- "severity": "medium",
- "file_path": "src/flask/cli.py",
- "function_name": "find_app_by_string",
- "line_start": 120,
- "line_end": 197,
- "details": {
- "bumps": 4,
- "ccn": 11,
- "max_nesting": 4
- },
- "health_impact": 0.132,
- "reason": "find_app_by_string has 4 nested blocks at the same level (bumpy road)",
- "status": "open",
- "suggestion": null,
- "dimension": "defect",
- "symbol_id": null
- },
- {
- "id": "cc5c719dea8b6a80d1476727",
- "biomarker_type": "bumpy_road",
- "severity": "low",
- "file_path": "src/flask/cli.py",
- "function_name": "find_best_app",
- "line_start": 41,
- "line_end": 91,
- "details": {
- "bumps": 3,
- "ccn": 10,
- "max_nesting": 5
- },
- "health_impact": 0.056,
- "reason": "find_best_app has 3 nested blocks at the same level (bumpy road)",
- "status": "open",
- "suggestion": null,
- "dimension": "defect",
- "symbol_id": null
- },
- {
- "id": "dd0194f456cad899e68c5882",
- "biomarker_type": "large_method",
- "severity": "low",
- "file_path": "src/flask/cli.py",
- "function_name": "find_app_by_string",
- "line_start": 120,
- "line_end": 197,
- "details": {
- "nloc": 68,
- "ccn": 11
- },
- "health_impact": 0.105,
- "reason": "find_app_by_string is 68 lines long",
- "status": "open",
- "suggestion": null,
- "dimension": "defect",
- "symbol_id": null
- },
- {
- "id": "35e3b26a20e7b8469cf29305",
- "biomarker_type": "primitive_obsession",
- "severity": "high",
- "file_path": "src/flask/cli.py",
- "function_name": "run_command",
- "line_start": 935,
- "line_end": 993,
- "details": {
- "param_count": 9
- },
- "health_impact": 0.168,
- "reason": "run_command takes 9 parameters",
- "status": "open",
- "suggestion": null,
- "dimension": "maintainability",
- "symbol_id": null
- },
- {
- "id": "692f1eafa18fac253c10a7cd",
- "biomarker_type": "primitive_obsession",
- "severity": "low",
- "file_path": "src/flask/cli.py",
- "function_name": "make_context",
- "line_start": 657,
- "line_end": 676,
- "details": {
- "param_count": 5
- },
- "health_impact": 0.042,
- "reason": "make_context takes 5 parameters",
- "status": "open",
- "suggestion": null,
- "dimension": "maintainability",
- "symbol_id": null
- },
- {
- "id": "928db1374c4f29d5737fac2d",
- "biomarker_type": "complex_conditional",
- "severity": "low",
- "file_path": "src/flask/cli.py",
- "function_name": "parse_args",
- "line_start": 679,
- "line_end": 679,
- "details": {
- "operator_count": 3,
- "enclosing_construct": "if"
- },
- "health_impact": 0.15,
- "reason": "if condition combines 3 boolean operators",
- "status": "open",
- "suggestion": null,
- "dimension": "defect",
- "symbol_id": null
- },
- {
- "id": "6def7c58d9285973cbd6f39d",
- "biomarker_type": "function_hotspot",
- "severity": "medium",
- "file_path": "src/flask/cli.py",
- "function_name": "routes_command",
- "line_start": 1061,
- "line_end": 1107,
- "details": {
- "modification_count": 6,
- "repo_p80": 5,
- "ccn": 13,
- "max_nesting": 3
- },
- "health_impact": 0.29,
- "reason": "routes_command has been modified across 6 commits (repo p80=5) and carries CCN=13 / nesting=3",
- "status": "open",
- "suggestion": null,
- "dimension": "defect",
- "symbol_id": null
- },
- {
- "id": "59d987fdc3c5b86b84f15d0f",
- "biomarker_type": "function_hotspot",
- "severity": "high",
- "file_path": "src/flask/cli.py",
- "function_name": "shell_command",
- "line_start": 1001,
- "line_end": 1045,
- "details": {
- "modification_count": 13,
- "repo_p80": 5,
- "ccn": 5,
- "max_nesting": 3
- },
- "health_impact": 0.497,
- "reason": "shell_command has been modified across 13 commits (repo p80=5) and carries CCN=5 / nesting=3",
- "status": "open",
- "suggestion": null,
- "dimension": "defect",
- "symbol_id": null
- },
- {
- "id": "b3c8a05d6fcfdb41ae13cefb",
- "biomarker_type": "function_hotspot",
- "severity": "high",
- "file_path": "src/flask/cli.py",
- "function_name": "run_command",
- "line_start": 935,
- "line_end": 993,
- "details": {
- "modification_count": 11,
- "repo_p80": 5,
- "ccn": 5,
- "max_nesting": 3
- },
- "health_impact": 0.497,
- "reason": "run_command has been modified across 11 commits (repo p80=5) and carries CCN=5 / nesting=3",
- "status": "open",
- "suggestion": null,
- "dimension": "defect",
- "symbol_id": null
- },
- {
- "id": "e1908844bfa38cece9505c6f",
- "biomarker_type": "function_hotspot",
- "severity": "medium",
- "file_path": "src/flask/cli.py",
- "function_name": "convert",
- "line_start": 791,
- "line_end": 825,
- "details": {
- "modification_count": 9,
- "repo_p80": 5,
- "ccn": 6,
- "max_nesting": 5
- },
- "health_impact": 0.29,
- "reason": "convert has been modified across 9 commits (repo p80=5) and carries CCN=6 / nesting=5",
- "status": "open",
- "suggestion": null,
- "dimension": "defect",
- "symbol_id": null
- },
- {
- "id": "58266b29c997afce37748eda",
- "biomarker_type": "function_hotspot",
- "severity": "medium",
- "file_path": "src/flask/cli.py",
- "function_name": "load_dotenv",
- "line_start": 698,
- "line_end": 763,
- "details": {
- "modification_count": 9,
- "repo_p80": 5,
- "ccn": 13,
- "max_nesting": 3
- },
- "health_impact": 0.29,
- "reason": "load_dotenv has been modified across 9 commits (repo p80=5) and carries CCN=13 / nesting=3",
- "status": "open",
- "suggestion": null,
- "dimension": "defect",
- "symbol_id": null
- },
- {
- "id": "f0ae5435d4f75d89f63cfa86",
- "biomarker_type": "function_hotspot",
- "severity": "high",
- "file_path": "src/flask/cli.py",
- "function_name": "load_app",
- "line_start": 333,
- "line_end": 372,
- "details": {
- "modification_count": 15,
- "repo_p80": 5,
- "ccn": 8,
- "max_nesting": 4
- },
- "health_impact": 0.497,
- "reason": "load_app has been modified across 15 commits (repo p80=5) and carries CCN=8 / nesting=4",
- "status": "open",
- "suggestion": null,
- "dimension": "defect",
- "symbol_id": null
- },
- {
- "id": "aee5b1828c3883a30621c4de",
- "biomarker_type": "function_hotspot",
- "severity": "high",
- "file_path": "src/flask/cli.py",
- "function_name": "find_app_by_string",
- "line_start": 120,
- "line_end": 197,
- "details": {
- "modification_count": 13,
- "repo_p80": 5,
- "ccn": 11,
- "max_nesting": 4
- },
- "health_impact": 0.497,
- "reason": "find_app_by_string has been modified across 13 commits (repo p80=5) and carries CCN=11 / nesting=4",
- "status": "open",
- "suggestion": null,
- "dimension": "defect",
- "symbol_id": null
- },
- {
- "id": "6ac160cd46a9479d6d2263b1",
- "biomarker_type": "function_hotspot",
- "severity": "high",
- "file_path": "src/flask/cli.py",
- "function_name": "find_best_app",
- "line_start": 41,
- "line_end": 91,
- "details": {
- "modification_count": 17,
- "repo_p80": 5,
- "ccn": 10,
- "max_nesting": 5
- },
- "health_impact": 0.497,
- "reason": "find_best_app has been modified across 17 commits (repo p80=5) and carries CCN=10 / nesting=5",
- "status": "open",
- "suggestion": null,
- "dimension": "defect",
- "symbol_id": null
- },
- {
- "id": "fb1070635166396549df3d9d",
- "biomarker_type": "ownership_risk",
- "severity": "low",
- "file_path": "src/flask/cli.py",
- "function_name": null,
- "line_start": null,
- "line_end": null,
- "details": {
- "minor_contributors": 16,
- "top_owner_share": 0.697,
- "contributor_count": 18,
- "total_commits": 66,
- "small_team": true
- },
- "health_impact": 0.148,
- "reason": "16 minor contributors (each <5% of commits); top owner holds 70% (informational: small team, 1 active contributors in 90d)",
- "status": "open",
- "suggestion": null,
- "dimension": "defect",
- "symbol_id": null
- },
- {
- "id": "19efd878bb50fe44398161e7",
- "biomarker_type": "error_handling",
- "severity": "low",
- "file_path": "src/flask/cli.py",
- "function_name": null,
- "line_start": 650,
- "line_end": 650,
- "details": {
- "kind": "bare_except"
- },
- "health_impact": 0.15,
- "reason": "catch-all except hides every error, including KeyboardInterrupt",
- "status": "open",
- "suggestion": null,
- "dimension": "maintainability",
- "symbol_id": null
- },
- {
- "id": "db511e524f8430078dc806c9",
- "biomarker_type": "error_handling",
- "severity": "low",
- "file_path": "src/flask/cli.py",
- "function_name": null,
- "line_start": 1036,
- "line_end": 1036,
- "details": {
- "kind": "swallowed_catch"
- },
- "health_impact": 0.15,
- "reason": "caught exception is swallowed without any handling",
- "status": "open",
- "suggestion": null,
- "dimension": "maintainability",
- "symbol_id": null
- },
- {
- "id": "1c5ab929fed77ec9ae5d3bf3",
- "biomarker_type": "error_handling",
- "severity": "low",
- "file_path": "src/flask/cli.py",
- "function_name": null,
- "line_start": 1098,
- "line_end": 1098,
- "details": {
- "kind": "swallowed_catch"
- },
- "health_impact": 0.15,
- "reason": "caught exception is swallowed without any handling",
- "status": "open",
- "suggestion": null,
- "dimension": "maintainability",
- "symbol_id": null
- },
- {
- "id": "21e7656ae601236104f81d2e",
- "biomarker_type": "hot_path_sync_io",
- "severity": "low",
- "file_path": "src/flask/cli.py",
- "function_name": "shell_command",
- "line_start": 1022,
- "line_end": 1022,
- "details": {
- "boundary_kind": "filesystem"
- },
- "health_impact": 0,
- "reason": "a blocking filesystem call runs on a hot, request-reachable path; its latency is paid on every call through this function",
- "status": "open",
- "suggestion": null,
- "dimension": "performance",
- "symbol_id": null
- },
- {
- "id": "866b5edd940c2fd3c736feb8",
- "biomarker_type": "dry_violation",
- "severity": "low",
- "file_path": "src/flask/globals.py",
- "function_name": null,
- "line_start": 18,
- "line_end": 28,
- "details": {
- "duplication_pct": 22.41,
- "clone_pair_count": 1,
- "worst_clone_lines": 11,
- "worst_clone_partner": "src/flask/globals.py",
- "worst_clone_co_change": 0
- },
- "health_impact": 0.15,
- "reason": "22% of file duplicated; worst clone shares 11 lines with src/flask/globals.py",
- "status": "open",
- "suggestion": null,
- "dimension": "maintainability",
- "symbol_id": null
- },
- {
- "id": "dd3381c1030aed17697543ea",
- "biomarker_type": "complex_method",
- "severity": "medium",
- "file_path": "src/flask/helpers.py",
- "function_name": "get_root_path",
- "line_start": 587,
- "line_end": 641,
- "details": {
- "ccn": 9,
- "cognitive": 12,
- "nloc": 45
- },
- "health_impact": 0.821,
- "reason": "get_root_path has cyclomatic complexity 9",
- "status": "open",
- "suggestion": null,
- "dimension": "defect",
- "symbol_id": null
- },
- {
- "id": "0da42a3887baa307c4485598",
- "biomarker_type": "primitive_obsession",
- "severity": "medium",
- "file_path": "src/flask/helpers.py",
- "function_name": "send_file",
- "line_start": 417,
- "line_end": 540,
- "details": {
- "param_count": 8
- },
- "health_impact": 0.339,
- "reason": "send_file takes 8 parameters",
- "status": "open",
- "suggestion": null,
- "dimension": "maintainability",
- "symbol_id": null
- },
- {
- "id": "1894a1e4e5d886fb52cbcbcf",
- "biomarker_type": "primitive_obsession",
- "severity": "medium",
- "file_path": "src/flask/helpers.py",
- "function_name": "url_for",
- "line_start": 200,
- "line_end": 251,
- "details": {
- "param_count": 7
- },
- "health_impact": 0.339,
- "reason": "url_for takes 7 parameters",
- "status": "open",
- "suggestion": null,
- "dimension": "maintainability",
- "symbol_id": null
- },
- {
- "id": "818bb7c32b8a0ac81c3afe7d",
- "biomarker_type": "ownership_risk",
- "severity": "low",
- "file_path": "src/flask/helpers.py",
- "function_name": null,
- "line_start": null,
- "line_end": null,
- "details": {
- "minor_contributors": 20,
- "top_owner_share": 0.636,
- "contributor_count": 22,
- "total_commits": 88,
- "small_team": true
- },
- "health_impact": 0.414,
- "reason": "20 minor contributors (each <5% of commits); top owner holds 64% (informational: small team, 1 active contributors in 90d)",
- "status": "open",
- "suggestion": null,
- "dimension": "defect",
- "symbol_id": null
- },
- {
- "id": "e3e3a4f918437a70cfea06c5",
- "biomarker_type": "complex_method",
- "severity": "medium",
- "file_path": "src/flask/debughelpers.py",
- "function_name": "explain_template_loading_attempts",
- "line_start": 124,
- "line_end": 179,
- "details": {
- "ccn": 13,
- "cognitive": 18,
- "nloc": 37
- },
- "health_impact": 0.847,
- "reason": "explain_template_loading_attempts has cyclomatic complexity 13",
- "status": "open",
- "suggestion": null,
- "dimension": "defect",
- "symbol_id": null
- },
- {
- "id": "fcb77b4c8e501e308d016f2b",
- "biomarker_type": "function_hotspot",
- "severity": "medium",
- "file_path": "src/flask/debughelpers.py",
- "function_name": "explain_template_loading_attempts",
- "line_start": 124,
- "line_end": 179,
- "details": {
- "modification_count": 8,
- "repo_p80": 5,
- "ccn": 13,
- "max_nesting": 3
- },
- "health_impact": 0.812,
- "reason": "explain_template_loading_attempts has been modified across 8 commits (repo p80=5) and carries CCN=13 / nesting=3",
- "status": "open",
- "suggestion": null,
- "dimension": "defect",
- "symbol_id": null
- },
- {
- "id": "ec30edc0a31e12eaa4c24baa",
- "biomarker_type": "function_hotspot",
- "severity": "medium",
- "file_path": "src/flask/debughelpers.py",
- "function_name": "_dump_loader_info",
- "line_start": 107,
- "line_end": 121,
- "details": {
- "modification_count": 6,
- "repo_p80": 5,
- "ccn": 7,
- "max_nesting": 3
- },
- "health_impact": 0.812,
- "reason": "_dump_loader_info has been modified across 6 commits (repo p80=5) and carries CCN=7 / nesting=3",
- "status": "open",
- "suggestion": null,
- "dimension": "defect",
- "symbol_id": null
- },
- {
- "id": "a268d5af746390e327d8c3e2",
- "biomarker_type": "brain_method",
- "severity": "high",
- "file_path": "src/flask/app.py",
- "function_name": "make_response",
- "line_start": 1224,
- "line_end": 1364,
- "details": {
- "ccn": 16,
- "nloc": 119,
- "max_nesting": 5,
- "dependents_count": 6,
- "centrality_floor": 5
- },
- "health_impact": 0.141,
- "reason": "Brain Method: make_response is 119 lines, CCN 16, in a file imported by 6 others",
- "status": "open",
- "suggestion": null,
- "dimension": "maintainability",
- "symbol_id": null
- },
- {
- "id": "bce878892996951400e98fad",
- "biomarker_type": "brain_method",
- "severity": "medium",
- "file_path": "src/flask/app.py",
- "function_name": "url_for",
- "line_start": 1102,
- "line_end": 1222,
- "details": {
- "ccn": 13,
- "nloc": 94,
- "max_nesting": 3,
- "dependents_count": 6,
- "centrality_floor": 5
- },
- "health_impact": 0.082,
- "reason": "Brain Method: url_for is 94 lines, CCN 13, in a file imported by 6 others",
- "status": "open",
- "suggestion": null,
- "dimension": "maintainability",
- "symbol_id": null
- },
- {
- "id": "5aba56e5bbdd42c6154c3f8b",
- "biomarker_type": "brain_method",
- "severity": "medium",
- "file_path": "src/flask/app.py",
- "function_name": "run",
- "line_start": 632,
- "line_end": 753,
- "details": {
- "ccn": 12,
- "nloc": 91,
- "max_nesting": 2,
- "dependents_count": 6,
- "centrality_floor": 5
- },
- "health_impact": 0.082,
- "reason": "Brain Method: run is 91 lines, CCN 12, in a file imported by 6 others",
- "status": "open",
- "suggestion": null,
- "dimension": "maintainability",
- "symbol_id": null
- },
- {
- "id": "b947e6b2fbf89f86347697af",
- "biomarker_type": "low_cohesion",
- "severity": "critical",
- "file_path": "src/flask/app.py",
- "function_name": "Flask",
- "line_start": 109,
- "line_end": 1625,
- "details": {
- "class_name": "Flask",
- "lcom4": 6,
- "method_count": 35,
- "field_count": 36
- },
- "health_impact": 0.234,
- "reason": "Flask has low cohesion (LCOM4=6): its 35 methods split into 6 groups that share no fields or calls",
- "status": "open",
- "suggestion": null,
- "dimension": "maintainability",
- "symbol_id": null
- },
- {
- "id": "352bff6fdeba1bb9c11a3be3",
- "biomarker_type": "god_class",
- "severity": "critical",
- "file_path": "src/flask/app.py",
- "function_name": "Flask",
- "line_start": 109,
- "line_end": 1625,
- "details": {
- "class_name": "Flask",
- "total_nloc": 1238,
- "method_count": 35,
- "max_method_ccn": 16
- },
- "health_impact": 0.53,
- "reason": "Flask is a god class: 1238 lines across 35 methods, including a brain method (max method CCN 16)",
- "status": "open",
- "suggestion": null,
- "dimension": "defect",
- "symbol_id": null
- }
- ],
- "modules": [
- {
- "module": "flask",
- "file_count": 11,
- "average_health": 7.35,
- "worst_file_path": "src/flask/app.py",
- "worst_file_score": 1.07,
- "nloc_weighted_health": 3.93,
- "critical_finding_count": 3,
- "warning_finding_count": 0
- },
- {
- "module": "flask/sansio",
- "file_count": 9,
- "average_health": 7.79,
- "worst_file_path": "src/flask/sansio/app.py",
- "worst_file_score": 1.35,
- "nloc_weighted_health": 5.62,
- "critical_finding_count": 5,
- "warning_finding_count": 0
- },
- {
- "module": "flask (6)",
- "file_count": 6,
- "average_health": 8.45,
- "worst_file_path": "src/flask/testing.py",
- "worst_file_score": 5.5,
- "nloc_weighted_health": 8.23,
- "critical_finding_count": 0,
- "warning_finding_count": 0
- },
- {
- "module": "tests",
- "file_count": 53,
- "average_health": 9.66,
- "worst_file_path": "src/flask/config.py",
- "worst_file_score": 5.15,
- "nloc_weighted_health": 8.61,
- "critical_finding_count": 0,
- "warning_finding_count": 0
- },
- {
- "module": "docs (1)",
- "file_count": 1,
- "average_health": 9.24,
- "worst_file_path": "docs/conf.py",
- "worst_file_score": 9.24,
- "nloc_weighted_health": 9.24,
- "critical_finding_count": 0,
- "warning_finding_count": 0
- },
- {
- "module": "config",
- "file_count": 1,
- "average_health": 10,
- "worst_file_path": ".pre-commit-config.yaml",
- "worst_file_score": 10,
- "nloc_weighted_health": 10,
- "critical_finding_count": 0,
- "warning_finding_count": 0
- },
- {
- "module": ".readthedocs",
- "file_count": 1,
- "average_health": 10,
- "worst_file_path": ".readthedocs.yaml",
- "worst_file_score": 10,
- "nloc_weighted_health": 10,
- "critical_finding_count": 0,
- "warning_finding_count": 0
- },
- {
- "module": "readme",
- "file_count": 1,
- "average_health": 10,
- "worst_file_path": "README.md",
- "worst_file_score": 10,
- "nloc_weighted_health": 10,
- "critical_finding_count": 0,
- "warning_finding_count": 0
- },
- {
- "module": "pyproject",
- "file_count": 1,
- "average_health": 10,
- "worst_file_path": "pyproject.toml",
- "worst_file_score": 10,
- "nloc_weighted_health": 10,
- "critical_finding_count": 0,
- "warning_finding_count": 0
- },
- {
- "module": "on-create-command",
- "file_count": 1,
- "average_health": 10,
- "worst_file_path": ".devcontainer/on-create-command.sh",
- "worst_file_score": 10,
- "nloc_weighted_health": 10,
- "critical_finding_count": 0,
- "warning_finding_count": 0
- },
- {
- "module": "pull_request_template",
- "file_count": 1,
- "average_health": 10,
- "worst_file_path": ".github/pull_request_template.md",
- "worst_file_score": 10,
- "nloc_weighted_health": 10,
- "critical_finding_count": 0,
- "warning_finding_count": 0
- },
- {
- "module": "issue_template",
- "file_count": 1,
- "average_health": 10,
- "worst_file_path": ".github/ISSUE_TEMPLATE/bug-report.md",
- "worst_file_score": 10,
- "nloc_weighted_health": 10,
- "critical_finding_count": 0,
- "warning_finding_count": 0
- },
- {
- "module": "issue_template (1)",
- "file_count": 2,
- "average_health": 10,
- "worst_file_path": ".github/ISSUE_TEMPLATE/config.yml",
- "worst_file_score": 10,
- "nloc_weighted_health": 10,
- "critical_finding_count": 0,
- "warning_finding_count": 0
- },
- {
- "module": "workflows",
- "file_count": 1,
- "average_health": 10,
- "worst_file_path": ".github/workflows/lock.yaml",
- "worst_file_score": 10,
- "nloc_weighted_health": 10,
- "critical_finding_count": 0,
- "warning_finding_count": 0
- },
- {
- "module": "devcontainer",
- "file_count": 1,
- "average_health": 10,
- "worst_file_path": ".devcontainer/devcontainer.json",
- "worst_file_score": 10,
- "nloc_weighted_health": 10,
- "critical_finding_count": 0,
- "warning_finding_count": 0
- },
- {
- "module": "workflows (1)",
- "file_count": 3,
- "average_health": 10,
- "worst_file_path": ".github/workflows/pre-commit.yaml",
- "worst_file_score": 10,
- "nloc_weighted_health": 10,
- "critical_finding_count": 0,
- "warning_finding_count": 0
- },
- {
- "module": "tests/test_apps",
- "file_count": 7,
- "average_health": 10,
- "worst_file_path": ".github/workflows/tests.yaml",
- "worst_file_score": 10,
- "nloc_weighted_health": 10,
- "critical_finding_count": 0,
- "warning_finding_count": 0
- },
- {
- "module": "docs",
- "file_count": 1,
- "average_health": 10,
- "worst_file_path": "docs/Makefile",
- "worst_file_score": 10,
- "nloc_weighted_health": 10,
- "critical_finding_count": 0,
- "warning_finding_count": 0
- },
- {
- "module": "examples/celery",
- "file_count": 1,
- "average_health": 10,
- "worst_file_path": "examples/celery/README.md",
- "worst_file_score": 10,
- "nloc_weighted_health": 10,
- "critical_finding_count": 0,
- "warning_finding_count": 0
- },
- {
- "module": "examples/celery (1)",
- "file_count": 1,
- "average_health": 10,
- "worst_file_path": "examples/celery/pyproject.toml",
- "worst_file_score": 10,
- "nloc_weighted_health": 10,
- "critical_finding_count": 0,
- "warning_finding_count": 0
- },
- {
- "module": "examples/javascript",
- "file_count": 1,
- "average_health": 10,
- "worst_file_path": "examples/javascript/pyproject.toml",
- "worst_file_score": 10,
- "nloc_weighted_health": 10,
- "critical_finding_count": 0,
- "warning_finding_count": 0
- },
- {
- "module": "examples/tutorial (1)",
- "file_count": 1,
- "average_health": 10,
- "worst_file_path": "examples/tutorial/pyproject.toml",
- "worst_file_score": 10,
- "nloc_weighted_health": 10,
- "critical_finding_count": 0,
- "warning_finding_count": 0
- },
- {
- "module": "examples/tutorial",
- "file_count": 1,
- "average_health": 10,
- "worst_file_path": "examples/tutorial/flaskr/schema.sql",
- "worst_file_score": 10,
- "nloc_weighted_health": 10,
- "critical_finding_count": 0,
- "warning_finding_count": 0
- },
- {
- "module": "flask/sansio (1)",
- "file_count": 1,
- "average_health": 10,
- "worst_file_path": "src/flask/sansio/README.md",
- "worst_file_score": 10,
- "nloc_weighted_health": 10,
- "critical_finding_count": 0,
- "warning_finding_count": 0
- }
- ],
- "defect_accuracy": {
- "k": 20,
- "hits": 5,
- "precision": 0.25,
- "base_rate": 0.0556,
- "lift": 4.5,
- "window_days": 180,
- "scored_files": 108,
- "defect_files": 6,
- "concentration_file_fraction": 0.2,
- "concentration_defect_share": 0.8333,
- "precision_table": [
- {
- "k": 10,
- "hits": 3
- },
- {
- "k": 20,
- "hits": 5
- },
- {
- "k": 30,
- "hits": 5
- }
- ],
- "flagged_files": [
- {
- "file_path": "src/flask/app.py",
- "score": 1.07,
- "recent_fixes": 1
- },
- {
- "file_path": "src/flask/sansio/app.py",
- "score": 1.35,
- "recent_fixes": 1
- },
- {
- "file_path": "src/flask/cli.py",
- "score": 2.05,
- "recent_fixes": 0
- },
- {
- "file_path": "src/flask/sansio/blueprints.py",
- "score": 3.53,
- "recent_fixes": 0
- },
- {
- "file_path": "src/flask/config.py",
- "score": 5.15,
- "recent_fixes": 0
- },
- {
- "file_path": "src/flask/testing.py",
- "score": 5.5,
- "recent_fixes": 0
- },
- {
- "file_path": "src/flask/ctx.py",
- "score": 6.51,
- "recent_fixes": 0
- },
- {
- "file_path": "src/flask/templating.py",
- "score": 7.15,
- "recent_fixes": 0
- },
- {
- "file_path": "src/flask/sansio/scaffold.py",
- "score": 7.16,
- "recent_fixes": 0
- },
- {
- "file_path": "tests/test_basic.py",
- "score": 7.49,
- "recent_fixes": 1
- },
- {
- "file_path": "src/flask/debughelpers.py",
- "score": 7.53,
- "recent_fixes": 0
- },
- {
- "file_path": "src/flask/helpers.py",
- "score": 8.09,
- "recent_fixes": 0
- },
- {
- "file_path": "tests/test_blueprints.py",
- "score": 8.14,
- "recent_fixes": 1
- },
- {
- "file_path": "tests/test_cli.py",
- "score": 8.19,
- "recent_fixes": 1
- },
- {
- "file_path": "src/flask/wrappers.py",
- "score": 8.59,
- "recent_fixes": 0
- },
- {
- "file_path": "src/flask/blueprints.py",
- "score": 8.64,
- "recent_fixes": 0
- },
- {
- "file_path": "tests/test_templating.py",
- "score": 8.74,
- "recent_fixes": 0
- },
- {
- "file_path": "tests/test_appctx.py",
- "score": 8.94,
- "recent_fixes": 0
- },
- {
- "file_path": "tests/test_reqctx.py",
- "score": 8.94,
- "recent_fixes": 0
- },
- {
- "file_path": "tests/test_testing.py",
- "score": 8.94,
- "recent_fixes": 0
- }
- ]
- },
- "meta": {
- "last_indexed_at": "2026-07-03T19:00:28.037767+00:00",
- "head_commit": "36e4a824f340fdee7ed50937ba8e7f6bc7d17f81",
- "snapshot_count": 1
- },
- "state": "ready",
- "reason": null
-}
diff --git a/packages/api-client/src/__fixtures__/hosted/health-trend.json b/packages/api-client/src/__fixtures__/hosted/health-trend.json
deleted file mode 100644
index 4738b7f78..000000000
--- a/packages/api-client/src/__fixtures__/hosted/health-trend.json
+++ /dev/null
@@ -1,15 +0,0 @@
-{
- "points": [
- {
- "taken_at": "2026-07-03T19:00:45.142832+00:00",
- "hotspot_health": 10,
- "average_health": 6.94,
- "worst_performer_path": "src/flask/app.py",
- "worst_performer_score": 1.07
- }
- ],
- "declining": false,
- "predicted_decline": false,
- "state": "ready",
- "reason": null
-}
diff --git a/packages/api-client/src/__fixtures__/hosted/hotspots.json b/packages/api-client/src/__fixtures__/hosted/hotspots.json
deleted file mode 100644
index 9f30ac51c..000000000
--- a/packages/api-client/src/__fixtures__/hosted/hotspots.json
+++ /dev/null
@@ -1,69 +0,0 @@
-{
- "items": [
- {
- "path": "src/flask/app.py",
- "commit_count": 134,
- "commit_count_90d": 0,
- "commit_count_30d": 0,
- "churn_percentile": 0.9880952380952381,
- "primary_owner": "pgjones",
- "last_commit_at": "2026-02-20T03:41:50+00:00",
- "is_hotspot": false,
- "is_stable": true,
- "bus_factor": 4,
- "contributor_count": 30,
- "lines_added_90d": 0,
- "lines_deleted_90d": 0,
- "avg_commit_size": 0,
- "commit_categories": {
- "fix": 16,
- "dependency": 3,
- "feature": 15,
- "refactor": 10
- },
- "commit_count_capped": false,
- "merge_commit_count_90d": 0,
- "recent_owner_name": null,
- "recent_owner_commit_pct": null,
- "temporal_hotspot_score": 1.7468812018086186,
- "change_entropy": 1.13513,
- "change_entropy_pct": 0.9705882352941176,
- "prior_defect_count": 1,
- "original_path": null
- },
- {
- "path": "src/flask/ctx.py",
- "commit_count": 44,
- "commit_count_90d": 1,
- "commit_count_30d": 0,
- "churn_percentile": 0.9761904761904762,
- "primary_owner": "David Lord",
- "last_commit_at": "2026-05-02T03:31:50+00:00",
- "is_hotspot": false,
- "is_stable": false,
- "bus_factor": 2,
- "contributor_count": 8,
- "lines_added_90d": 5,
- "lines_deleted_90d": 5,
- "avg_commit_size": 10,
- "commit_categories": {
- "feature": 5,
- "dependency": 1,
- "fix": 6,
- "refactor": 2
- },
- "commit_count_capped": false,
- "merge_commit_count_90d": 0,
- "recent_owner_name": "David Lord",
- "recent_owner_commit_pct": 1,
- "temporal_hotspot_score": 1.7200224452756603,
- "change_entropy": 1.101266,
- "change_entropy_pct": 0.9558823529411765,
- "prior_defect_count": 0,
- "original_path": null
- }
- ],
- "total": 83,
- "has_more": true,
- "next_offset": 2
-}
diff --git a/packages/api-client/src/__fixtures__/hosted/module-graph.json b/packages/api-client/src/__fixtures__/hosted/module-graph.json
deleted file mode 100644
index fadf13a4b..000000000
--- a/packages/api-client/src/__fixtures__/hosted/module-graph.json
+++ /dev/null
@@ -1,59 +0,0 @@
-{
- "nodes": [
- {
- "module_id": ".pre-commit-config.yaml",
- "file_count": 1,
- "symbol_count": 0,
- "avg_pagerank": 0.002136,
- "doc_coverage_pct": 0
- },
- {
- "module_id": ".readthedocs.yaml",
- "file_count": 1,
- "symbol_count": 0,
- "avg_pagerank": 0.002136,
- "doc_coverage_pct": 0
- },
- {
- "module_id": "README.md",
- "file_count": 1,
- "symbol_count": 0,
- "avg_pagerank": 0.002136,
- "doc_coverage_pct": 0
- }
- ],
- "edges": [
- {
- "source": "examples",
- "target": "src",
- "edge_count": 10
- },
- {
- "source": "src",
- "target": "tests",
- "edge_count": 5
- },
- {
- "source": "tests",
- "target": "src",
- "edge_count": 64
- }
- ],
- "links": [
- {
- "source": "examples",
- "target": "src",
- "edge_count": 10
- },
- {
- "source": "src",
- "target": "tests",
- "edge_count": 5
- },
- {
- "source": "tests",
- "target": "src",
- "edge_count": 64
- }
- ]
-}
diff --git a/packages/api-client/src/__fixtures__/hosted/modules-health.json b/packages/api-client/src/__fixtures__/hosted/modules-health.json
deleted file mode 100644
index b314bf300..000000000
--- a/packages/api-client/src/__fixtures__/hosted/modules-health.json
+++ /dev/null
@@ -1,58 +0,0 @@
-{
- "items": [
- {
- "module_path": "docs",
- "file_count": 1,
- "symbol_count": 24,
- "hotspot_count": 0,
- "dead_code_count": 2,
- "dead_code_lines": 241,
- "avg_churn_percentile": 61.904761904761905,
- "median_bus_factor": 2,
- "min_bus_factor": 2,
- "primary_owner": "David Lord",
- "primary_owner_pct": 1,
- "is_silo": true,
- "decision_count": 0,
- "doc_coverage_pct": 0,
- "health_score": 25.714285714285715
- },
- {
- "module_path": "examples",
- "file_count": 17,
- "symbol_count": 62,
- "hotspot_count": 0,
- "dead_code_count": 2,
- "dead_code_lines": 40,
- "avg_churn_percentile": 35.22408963585434,
- "median_bus_factor": 1,
- "min_bus_factor": 1,
- "primary_owner": "David Lord",
- "primary_owner_pct": 1,
- "is_silo": true,
- "decision_count": 0,
- "doc_coverage_pct": 32.25806451612903,
- "health_score": 61.613919761452976
- },
- {
- "module_path": "src",
- "file_count": 24,
- "symbol_count": 495,
- "hotspot_count": 0,
- "dead_code_count": 9,
- "dead_code_lines": 76,
- "avg_churn_percentile": 73.26388888888889,
- "median_bus_factor": 2,
- "min_bus_factor": 1,
- "primary_owner": "David Lord",
- "primary_owner_pct": 0.8333333333333334,
- "is_silo": true,
- "decision_count": 21,
- "doc_coverage_pct": 51.515151515151516,
- "health_score": 72.3626893939394
- }
- ],
- "total": 5,
- "has_more": true,
- "next_offset": 3
-}
diff --git a/packages/api-client/src/__fixtures__/hosted/overview-summary.json b/packages/api-client/src/__fixtures__/hosted/overview-summary.json
deleted file mode 100644
index 4dc7998a1..000000000
--- a/packages/api-client/src/__fixtures__/hosted/overview-summary.json
+++ /dev/null
@@ -1,117 +0,0 @@
-{
- "repo": {
- "id": "d8ea204a-6325-438c-a805-fbdb029ffd11",
- "name": "flask",
- "owner": "pallets",
- "is_public": true,
- "local_path": "github.com/pallets/flask",
- "updated_at": "2026-07-03T19:00:28.037767+00:00",
- "head_commit": "36e4a824f340fdee7ed50937ba8e7f6bc7d17f81",
- "default_branch": "main"
- },
- "sync": {
- "page_count": 0,
- "last_sync_at": "2026-07-03T19:00:28.037767+00:00",
- "active_job_id": null,
- "last_resync_at": null,
- "last_sync_model": null
- },
- "stats": {
- "deltas": {
- "file_count": null,
- "average_health": null,
- "hotspot_health": null
- },
- "file_count": 108,
- "silo_count": 4,
- "module_count": 24,
- "symbol_count": 1060,
- "hotspot_count": 0,
- "freshness_score": 0,
- "doc_coverage_pct": 0,
- "dead_export_count": 12,
- "entry_point_count": 5
- },
- "health": {
- "history": [
- {
- "taken_at": "2026-07-03T19:00:45.142832+00:00",
- "average_health": 6.94,
- "hotspot_health": 10
- }
- ],
- "open_findings": 209,
- "average_health": 6.94,
- "hotspot_health": 10,
- "snapshot_count": 1,
- "last_indexed_at": "2026-07-03T19:00:45.142832+00:00",
- "severity_breakdown": {
- "low": 85,
- "high": 32,
- "medium": 84,
- "critical": 8
- },
- "performance_average": 9.96,
- "performance_findings": 4,
- "worst_performer_path": "src/flask/app.py",
- "worst_performer_score": 1.07,
- "worst_performance_path": "src/flask/app.py",
- "maintainability_average": 7.71,
- "worst_performance_score": 9.7
- },
- "savings": {
- "available": false
- },
- "attention": [
- {
- "id": "proposed-9827083f96ad4d149c9d983a7e59a9bc",
- "type": "proposed_decision",
- "title": "Windows env var keys are always uppercase.",
- "severity": "medium",
- "target_id": "9827083f96ad4d149c9d983a7e59a9bc",
- "description": "Auto-proposed decision awaiting review"
- },
- {
- "id": "proposed-d4175eb5203c426abeb80cd320a55136",
- "type": "proposed_decision",
- "title": "do this instead of startswith for nicer pytest output",
- "severity": "medium",
- "target_id": "d4175eb5203c426abeb80cd320a55136",
- "description": "Auto-proposed decision awaiting review"
- }
- ],
- "languages": [
- {
- "language": "python",
- "file_count": 83
- },
- {
- "language": "yaml",
- "file_count": 8
- },
- {
- "language": "markdown",
- "file_count": 6
- }
- ],
- "top_hotspots": [],
- "recent_decisions": [
- {
- "id": "9827083f96ad4d149c9d983a7e59a9bc",
- "title": "Windows env var keys are always uppercase.",
- "source": "code_comment",
- "status": "proposed",
- "created_at": null,
- "staleness_score": 0
- },
- {
- "id": "d4175eb5203c426abeb80cd320a55136",
- "title": "do this instead of startswith for nicer pytest output",
- "source": "code_comment",
- "status": "proposed",
- "created_at": null,
- "staleness_score": 0
- }
- ],
- "onboarding_targets": []
-}
diff --git a/packages/api-client/src/__fixtures__/hosted/recommendation-plans.json b/packages/api-client/src/__fixtures__/hosted/recommendation-plans.json
deleted file mode 100644
index 2496cef0b..000000000
--- a/packages/api-client/src/__fixtures__/hosted/recommendation-plans.json
+++ /dev/null
@@ -1,24 +0,0 @@
-{
- "summary": {
- "total": 1,
- "by_type": [{ "type": "extract_method", "count": 1 }]
- },
- "plans": [
- {
- "id": "legacy-plan",
- "refactoring_type": "extract_method",
- "file_path": "src/app.py",
- "target_symbol": "run",
- "line_start": 10,
- "line_end": 40,
- "plan": {},
- "evidence": {},
- "impact_delta": 1.25,
- "effort_bucket": "M",
- "blast_radius": {},
- "confidence": "medium",
- "source_biomarker": "complex_method",
- "rank_score": 1.5
- }
- ]
-}
diff --git a/packages/api-client/src/__fixtures__/hosted/refactoring-targets.json b/packages/api-client/src/__fixtures__/hosted/refactoring-targets.json
deleted file mode 100644
index cd491c657..000000000
--- a/packages/api-client/src/__fixtures__/hosted/refactoring-targets.json
+++ /dev/null
@@ -1,204 +0,0 @@
-{
- "targets": [
- {
- "file_path": "src/flask/__init__.py",
- "score": 9.24,
- "impact": 0.76,
- "effort": 0.2,
- "biomarkers": [
- {
- "id": "a254a623ca40c0367121f788",
- "biomarker_type": "dry_violation",
- "severity": "medium",
- "file_path": "src/flask/__init__.py",
- "function_name": null,
- "line_start": 1,
- "line_end": 38,
- "details": {
- "duplication_pct": 100,
- "clone_pair_count": 1,
- "worst_clone_lines": 38,
- "worst_clone_partner": "src/flask/__init__.py",
- "worst_clone_co_change": 0
- },
- "health_impact": 0.35,
- "reason": "100% of file duplicated; worst clone shares 38 lines with src/flask/__init__.py",
- "status": "open",
- "suggestion": "Duplicated logic detected — extract the shared code path.",
- "dimension": "maintainability",
- "symbol_id": null
- },
- {
- "id": "8510993cad8a38502173828e",
- "biomarker_type": "ownership_risk",
- "severity": "low",
- "file_path": "src/flask/__init__.py",
- "function_name": null,
- "line_start": null,
- "line_end": null,
- "details": {
- "minor_contributors": 6,
- "top_owner_share": 0.9,
- "contributor_count": 7,
- "total_commits": 70,
- "small_team": true
- },
- "health_impact": 0.414,
- "reason": "6 minor contributors (each <5% of commits); top owner holds 90% (informational: small team, 1 active contributors in 90d)",
- "status": "open",
- "suggestion": "Review and refactor according to the biomarker details.",
- "dimension": "defect",
- "symbol_id": null
- }
- ]
- },
- {
- "file_path": "src/flask/testing.py",
- "score": 5.5,
- "impact": 4.5,
- "effort": 1.91,
- "biomarkers": [
- {
- "id": "5a4894573329adb5f7f26a2e",
- "biomarker_type": "complex_method",
- "severity": "medium",
- "file_path": "src/flask/testing.py",
- "function_name": "__init__",
- "line_start": 49,
- "line_end": 86,
- "details": {
- "ccn": 12,
- "cognitive": 14,
- "nloc": 22
- },
- "health_impact": 0.847,
- "reason": "__init__ has cyclomatic complexity 12",
- "status": "open",
- "suggestion": "Reduce cyclomatic complexity by extracting decision points into helper functions.",
- "dimension": "defect",
- "symbol_id": null
- },
- {
- "id": "b5d910a7b0b8ffd956e186ab",
- "biomarker_type": "primitive_obsession",
- "severity": "low",
- "file_path": "src/flask/testing.py",
- "function_name": "invoke",
- "line_start": 275,
- "line_end": 298,
- "details": {
- "param_count": 5
- },
- "health_impact": 0.15,
- "reason": "invoke takes 5 parameters",
- "status": "open",
- "suggestion": "Replace cluster of primitive parameters with a small value-object.",
- "dimension": "maintainability",
- "symbol_id": null
- },
- {
- "id": "0f932e1ea251b154a4eec694",
- "biomarker_type": "primitive_obsession",
- "severity": "low",
- "file_path": "src/flask/testing.py",
- "function_name": "__init__",
- "line_start": 49,
- "line_end": 86,
- "details": {
- "param_count": 8
- },
- "health_impact": 0.15,
- "reason": "__init__ takes 8 parameters",
- "status": "open",
- "suggestion": "Replace cluster of primitive parameters with a small value-object.",
- "dimension": "maintainability",
- "symbol_id": null
- },
- {
- "id": "2592aedd72c16c25e33e2318",
- "biomarker_type": "primitive_obsession",
- "severity": "low",
- "file_path": "src/flask/testing.py",
- "function_name": "open",
- "line_start": 204,
- "line_end": 247,
- "details": {
- "param_count": 5
- },
- "health_impact": 0.15,
- "reason": "open takes 5 parameters",
- "status": "open",
- "suggestion": "Replace cluster of primitive parameters with a small value-object.",
- "dimension": "maintainability",
- "symbol_id": null
- },
- {
- "id": "239a78b51ac69856aa1c46fa",
- "biomarker_type": "function_hotspot",
- "severity": "high",
- "file_path": "src/flask/testing.py",
- "function_name": "__init__",
- "line_start": 49,
- "line_end": 86,
- "details": {
- "modification_count": 10,
- "repo_p80": 5,
- "ccn": 12,
- "max_nesting": 2
- },
- "health_impact": 1.392,
- "reason": "__init__ has been modified across 10 commits (repo p80=5) and carries CCN=12 / nesting=2",
- "status": "open",
- "suggestion": "Review and refactor according to the biomarker details.",
- "dimension": "defect",
- "symbol_id": null
- },
- {
- "id": "7e881daa9d798d7b9228b510",
- "biomarker_type": "function_hotspot",
- "severity": "high",
- "file_path": "src/flask/testing.py",
- "function_name": "open",
- "line_start": 204,
- "line_end": 247,
- "details": {
- "modification_count": 12,
- "repo_p80": 5,
- "ccn": 7,
- "max_nesting": 3
- },
- "health_impact": 1.392,
- "reason": "open has been modified across 12 commits (repo p80=5) and carries CCN=7 / nesting=3",
- "status": "open",
- "suggestion": "Review and refactor according to the biomarker details.",
- "dimension": "defect",
- "symbol_id": null
- },
- {
- "id": "7bb853f727b7391545d28836",
- "biomarker_type": "ownership_risk",
- "severity": "low",
- "file_path": "src/flask/testing.py",
- "function_name": null,
- "line_start": null,
- "line_end": null,
- "details": {
- "minor_contributors": 3,
- "top_owner_share": 0.868,
- "contributor_count": 5,
- "total_commits": 38,
- "small_team": true
- },
- "health_impact": 0.414,
- "reason": "3 minor contributors (each <5% of commits); top owner holds 87% (informational: small team, 1 active contributors in 90d)",
- "status": "open",
- "suggestion": "Review and refactor according to the biomarker details.",
- "dimension": "defect",
- "symbol_id": null
- }
- ]
- }
- ],
- "state": "ready",
- "reason": null
-}
diff --git a/packages/api-client/src/__fixtures__/hosted/search.json b/packages/api-client/src/__fixtures__/hosted/search.json
deleted file mode 100644
index 2f50e875f..000000000
--- a/packages/api-client/src/__fixtures__/hosted/search.json
+++ /dev/null
@@ -1,28 +0,0 @@
-{
- "results": [
- {
- "title": "Set with env var instead of ScriptInfo.load so that it can be accessed early during a factory functi",
- "page_type": "decision_record",
- "target_path": "decision:26c8470eb1f84a45987e4276c0e3b982",
- "snippet": "Set with env var instead of ScriptInfo.load so that it can be accessed early during a factory functi\nSet with env var instead of ScriptInfo.load so that it can be accessed early during a factory function.",
- "score": 0.370858750216633,
- "search_type": "semantic"
- },
- {
- "title": "Handle app factory errors by distinguishing TypeError from factory-raised errors",
- "page_type": "decision_record",
- "target_path": "decision:c6c45112396544979af05342c09476e5",
- "snippet": "Handle app factory errors by distinguishing TypeError from factory-raised errors\nTreat a TypeError as indicating call failure only if it was raised because the call failed, not because something inside the factory raised the error.",
- "score": 0.348739732750966,
- "search_type": "semantic"
- },
- {
- "title": "Processing is done with option callbacks instead of a group callback. This allows users to make a cu",
- "page_type": "decision_record",
- "target_path": "decision:aa9c9a7359724a22842a61146e730b9a",
- "snippet": "Processing is done with option callbacks instead of a group callback. This allows users to make a cu\nProcessing is done with option callbacks instead of a group callback. This allows users to make a custom group callback without losing the ",
- "score": 0.336411976817619,
- "search_type": "semantic"
- }
- ]
-}
diff --git a/packages/api-client/src/__fixtures__/hosted/snapshot-status.json b/packages/api-client/src/__fixtures__/hosted/snapshot-status.json
deleted file mode 100644
index d9a2dbae3..000000000
--- a/packages/api-client/src/__fixtures__/hosted/snapshot-status.json
+++ /dev/null
@@ -1,24 +0,0 @@
-{
- "id": "85db9d2fcd56506c52ffe8a430e32bd2ef65ca02d888a6dcd1f02a33505df627",
- "short_id": "85db9d2fcd56",
- "repo_id": "d8ea204a-6325-438c-a805-fbdb029ffd11",
- "head_sha": "36e4a824f340fdee7ed50937ba8e7f6bc7d17f81",
- "commit_depth": 2000,
- "status": "ready",
- "error_message": null,
- "file_count": 108,
- "line_count": null,
- "indexing_duration_seconds": 18,
- "created_at": "2026-07-03T19:00:28.037767Z",
- "completed_at": "2026-07-03T19:01:16.335012Z",
- "ref": "main",
- "generate_docs": false,
- "docs_file_percentage": null,
- "reaped_at": null,
- "superseded_by_short_id": null,
- "triggered_by_kind": null,
- "triggered_by_installation_id": null,
- "docs_status": "skipped",
- "docs_pages_ready": 0,
- "docs_pages_total": null
-}
diff --git a/packages/api-client/src/__fixtures__/hosted/stats-highlights.json b/packages/api-client/src/__fixtures__/hosted/stats-highlights.json
deleted file mode 100644
index b86c54958..000000000
--- a/packages/api-client/src/__fixtures__/hosted/stats-highlights.json
+++ /dev/null
@@ -1,379 +0,0 @@
-{
- "repo": {
- "id": "repo-1",
- "name": "demo"
- },
- "scale": {
- "file_count": 3146,
- "symbol_count": 24430,
- "module_count": 11,
- "total_nloc": 419590,
- "language_count": 12,
- "languages": [
- {
- "language": "python",
- "file_count": 1803
- },
- {
- "language": "typescript",
- "file_count": 1001
- },
- {
- "language": "markdown",
- "file_count": 144
- },
- {
- "language": "json",
- "file_count": 85
- }
- ],
- "size_class": {
- "name": "Metropolis",
- "blurb": "A sprawling metropolis with serious infrastructure.",
- "nloc": 419590
- }
- },
- "origin": {
- "first_commit_at": "2026-03-23T16:14:58+00:00",
- "first_commit_author": "RaghavChamadiya",
- "first_commit_subject": "Initial commit: CodeWiki project",
- "last_commit_at": "2026-07-25T18:00:21+00:00",
- "age_days": 124,
- "total_commits": 854,
- "contributor_count": 51
- },
- "churn": {
- "lines_added": 740846,
- "lines_deleted": 160171,
- "net": 580675,
- "deleted_per_hundred": 21.6
- },
- "rhythm": {
- "punch_card": {
- "matrix": [
- [
- 2,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 1,
- 9,
- 5,
- 6,
- 5,
- 8,
- 12,
- 10,
- 4,
- 4,
- 11,
- 5,
- 0,
- 3,
- 4
- ],
- [
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 4,
- 1,
- 3,
- 8,
- 13,
- 16,
- 4,
- 5,
- 5,
- 6,
- 5,
- 3,
- 6,
- 2
- ],
- [
- 1,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 1,
- 1,
- 4,
- 8,
- 7,
- 17,
- 12,
- 13,
- 11,
- 11,
- 7,
- 2,
- 16,
- 8,
- 4,
- 4
- ],
- [
- 3,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 3,
- 9,
- 4,
- 0,
- 9,
- 16,
- 19,
- 15,
- 4,
- 9,
- 12,
- 6,
- 1,
- 7
- ],
- [
- 1,
- 2,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 3,
- 6,
- 16,
- 10,
- 11,
- 25,
- 13,
- 13,
- 13,
- 7,
- 6,
- 8,
- 10,
- 4,
- 7
- ],
- [
- 4,
- 3,
- 0,
- 0,
- 0,
- 0,
- 0,
- 2,
- 3,
- 1,
- 9,
- 15,
- 7,
- 10,
- 18,
- 18,
- 16,
- 18,
- 15,
- 17,
- 7,
- 4,
- 4,
- 4
- ],
- [
- 1,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 1,
- 1,
- 9,
- 9,
- 8,
- 5,
- 21,
- 22,
- 10,
- 13,
- 2,
- 4,
- 0,
- 1,
- 2
- ]
- ],
- "peak": {
- "weekday": 4,
- "hour": 14,
- "count": 25
- },
- "busiest_weekday": 5,
- "peak_hour": 15,
- "total": 853,
- "timezone_mode": "author_local"
- },
- "velocity": {
- "recent_90d": 742,
- "prior_90d": 111,
- "pct_change": 568.5
- },
- "busiest_month": {
- "month": "2026-07",
- "total": 351
- },
- "busiest_day": {
- "date": "2026-07-24",
- "commits": 37
- },
- "longest_streak": {
- "days": 25,
- "start": "2026-05-23",
- "end": "2026-06-16"
- },
- "active_days": 95,
- "code_half_life_days": 28
- },
- "people": {
- "owner_count": 28,
- "single_owner_files": 2820,
- "silo_count": 9,
- "truck_factor": 1,
- "contributor_count": 51,
- "chronotypes": [
- {
- "name": "Raghav Chamadiya",
- "commits": 626,
- "peak_hour": 15,
- "label": "daylight",
- "night_pct": 9.6,
- "early_pct": 0.8
- },
- {
- "name": "Swati Ahuja",
- "commits": 90,
- "peak_hour": 15,
- "label": "daylight",
- "night_pct": 10.0,
- "early_pct": 0.0
- },
- {
- "name": "joptimus",
- "commits": 25,
- "peak_hour": 13,
- "label": "daylight",
- "night_pct": 0.0,
- "early_pct": 0.0
- }
- ],
- "arrivals": [
- {
- "name": "Raghav Chamadiya",
- "first_commit_at": "2026-03-23T09:14:58+00:00"
- },
- {
- "name": "Swati Ahuja",
- "first_commit_at": "2026-03-29T07:34:55+00:00"
- },
- {
- "name": "Adam Franke",
- "first_commit_at": "2026-04-03T07:20:45+00:00"
- },
- {
- "name": "Lakshay Sachdeva",
- "first_commit_at": "2026-04-03T12:53:35+00:00"
- },
- {
- "name": "Gabriel Mitelman Tkacz",
- "first_commit_at": "2026-04-04T09:56:16+00:00"
- }
- ]
- },
- "records": {
- "largest_file": {
- "path": "packages/api-client/src/__fixtures__/hosted/health-overview.json",
- "nloc": 1707
- },
- "gnarliest_file": {
- "path": "packages/server/src/repowise/server/mcp_server/tool_answer/answer.py",
- "max_ccn": 166
- },
- "most_complex_symbol": {
- "name": "get_answer",
- "file_path": "packages/server/src/repowise/server/mcp_server/tool_answer/answer.py",
- "complexity": 166
- },
- "most_changed_file": {
- "path": "uv.lock",
- "commit_count": 65
- },
- "oldest_file": {
- "path": "package-lock.json",
- "first_commit_at": "2026-03-23T09:14:58+00:00"
- },
- "most_central_file": {
- "path": "packages/core/src/repowise/core/persistence/models.py",
- "pagerank": 0.0098,
- "import_count": 188
- },
- "strongest_coupling": {
- "a": "packages/cli/src/repowise/cli/__init__.py",
- "b": "pyproject.toml",
- "count": 42.51
- },
- "largest_cycle": {
- "files": 151,
- "cycle_count": 18
- },
- "symbol_shape": {
- "total": 24412,
- "async_count": 2882,
- "async_pct": 11.8,
- "documented_count": 6461,
- "documented_pct": 26.5
- },
- "biggest_commit": {
- "sha": "a901cc985cbd47634a45dc50ddab2d80f2c36cc4",
- "subject": "feat: v0.3.0 \u2014 workspaces, auto-sync hooks, graph intelligence (#76)",
- "lines_changed": 27519,
- "files_changed": 187
- },
- "widest_commit": {
- "sha": "aadd8f5e022208cc0901bd34d03bd6287aee43a6",
- "subject": "release: v0.5.0 \u2014 frontend monorepo restructure, build hardening, jobs reliability (#132)",
- "files_changed": 278,
- "lines_changed": 20715
- }
- }
-}
diff --git a/packages/api-client/src/hosted.fixtures.test.ts b/packages/api-client/src/hosted.fixtures.test.ts
deleted file mode 100644
index c0acd83f4..000000000
--- a/packages/api-client/src/hosted.fixtures.test.ts
+++ /dev/null
@@ -1,219 +0,0 @@
-/**
- * Shape-compat tests: recorded responses from the live hosted API, replayed
- * through the provider and pinned to the shared OSS types. The assignments
- * below are the contract; if a hosted route drifts from the OSS shape, the
- * re-recorded fixture stops satisfying the type or these key-field checks.
- *
- * Fixtures live in __fixtures__/hosted/, recorded from public snapshots
- * (pallets/flask for data domains, repowise for docs) and trimmed to a few
- * entries. Re-record with a fresh snapshot id when the contract changes.
- */
-
-import { readFileSync } from "node:fs";
-import path from "node:path";
-import { fileURLToPath } from "node:url";
-import { describe, expect, it } from "vitest";
-
-import type { FileDetailResponse, FilesIndexResponse } from "@repowise-dev/types/files";
-import type {
- ChurnComplexityResponse,
- HealthFilesResponse,
- HealthFinding,
- HealthOverviewResponse,
- HealthTrendResponse,
- HealthWorkQueueResponse,
-} from "@repowise-dev/types/health";
-import type { OverviewSummaryResponse } from "@repowise-dev/types/overview";
-import type { RefactoringTargets } from "@repowise-dev/types/refactoring";
-import type { StatsHighlights } from "@repowise-dev/types/stats";
-import { createHostedProvider, type HostedProvider } from "./hosted";
-import type {
- ArchitectureGraphResponse,
- HotspotResponse,
- ModuleGraphResponse,
- Paginated,
-} from "./types";
-
-const FIXTURES = path.join(path.dirname(fileURLToPath(import.meta.url)), "__fixtures__", "hosted");
-
-function fixture(name: string): unknown {
- return JSON.parse(readFileSync(path.join(FIXTURES, `${name}.json`), "utf-8"));
-}
-
-const REPO = {
- repo: {
- id: "repo-1",
- canonical_url: "github.com/pallets/flask",
- owner: "pallets",
- name: "flask",
- default_branch: "main",
- latest_known_head_sha: null,
- is_public: true,
- },
- active_snapshot: { id: "snap-1", short_id: "snap-1", status: "ready" },
-};
-
-/** Provider whose fetch serves each snapshot route from its fixture. */
-function fixtureProvider(routes: Array<[string, string]>): HostedProvider {
- const table: Array<[string, unknown]> = routes.map(([suffix, name]) => [suffix, fixture(name)]);
- return createHostedProvider({
- baseUrl: "https://api.example.dev",
- fetch: (async (url: string | URL) => {
- const u = String(url);
- if (u.includes("/repos/mine")) return json([REPO]);
- for (const [suffix, body] of table) {
- if (u.includes(suffix)) return json(body);
- }
- throw new Error(`no fixture route for ${u}`);
- }) as typeof fetch,
- });
-}
-
-function json(body: unknown): Response {
- return new Response(JSON.stringify(body), {
- status: 200,
- headers: { "Content-Type": "application/json" },
- });
-}
-
-describe("hosted fixtures satisfy the OSS contracts", () => {
- it("health overview / files / findings / trend", async () => {
- const p = fixtureProvider([
- ["/health/overview", "health-overview"],
- ["/health/files/breakdown", "health-files"], // unused; ordering guard
- ["/health/findings", "health-findings"],
- ["/health/files", "health-files"],
- ["/health/trend", "health-trend"],
- ["/health/churn-complexity", "churn-complexity"],
- ["/health/refactoring-targets", "refactoring-targets"],
- ["/refactoring/targets", "recommendation-plans"],
- ]);
- const overview: HealthOverviewResponse = await p.getHealthOverview("repo-1");
- expect(overview.summary.file_count).toBeGreaterThan(0);
- expect(overview.summary.average_health).toBeTypeOf("number");
- expect(typeof overview.summary.open_findings).toBe("number");
- expect(Array.isArray(overview.files)).toBe(true);
- expect(overview.top_findings[0]).toHaveProperty("biomarker_type");
-
- const files: HealthFilesResponse = await p.listHealthFiles("repo-1");
- expect(files.files[0]).toHaveProperty("file_path");
- expect(files.files[0]).toHaveProperty("score");
- expect(typeof files.total).toBe("number");
-
- const findings: HealthFinding[] = await p.listHealthFindings("repo-1");
- expect(findings[0]).toHaveProperty("biomarker_type");
- expect(findings[0]).toHaveProperty("severity");
-
- const trend: HealthTrendResponse = await p.getHealthTrend("repo-1");
- expect(Array.isArray(trend.history)).toBe(true);
- expect(trend.summary).toHaveProperty("current_hotspot_health");
-
- const churn: ChurnComplexityResponse = await p.getChurnComplexity("repo-1");
- expect(Array.isArray(churn.points)).toBe(true);
-
- const targets: HealthWorkQueueResponse = await p.getHealthWorkQueue("repo-1");
- expect(Array.isArray(targets.targets)).toBe(true);
- const legacyTargets: HealthWorkQueueResponse = await p.getRefactoringTargets("repo-1");
- expect(legacyTargets).toEqual(targets);
-
- const plans: RefactoringTargets = await p.getRefactoringPlans("repo-1");
- expect(plans.plans[0]?.rank_score).toBeTypeOf("number");
- // Recorded older-server payload: the newer fields are intentionally absent.
- expect(plans.plans[0]?.validation).toBeUndefined();
- });
-
- it("overview summary and stats highlights", async () => {
- const p = fixtureProvider([
- ["/overview-summary", "overview-summary"],
- ["/stats/highlights", "stats-highlights"],
- ]);
- const summary: OverviewSummaryResponse = await p.getOverviewSummary("repo-1");
- expect(summary.repo).toBeDefined();
- expect(summary.health).toBeDefined();
- expect(summary.sync).toBeDefined();
-
- // Assert every top-level section, not just two. `getStatsHighlights` is a
- // bare passthrough with no field mapping, so this fixture is the only thing
- // standing between a hosted payload drifting from the contract and the
- // Stats page rendering `undefined` sections at runtime.
- const stats: StatsHighlights = await p.getStatsHighlights("repo-1");
- expect(stats.scale.size_class.name).toBeTruthy();
- expect(stats.origin).toBeDefined();
- expect(stats.rhythm.punch_card.matrix).toHaveLength(7);
- expect(stats.rhythm.punch_card.matrix[0]).toHaveLength(24);
- expect(["author_local", "utc"]).toContain(stats.rhythm.punch_card.timezone_mode);
- expect(stats.people.arrivals).toBeInstanceOf(Array);
- expect(stats.people.chronotypes).toBeInstanceOf(Array);
- expect(stats.records).toBeDefined();
- // `churn` is legitimately null when the history was too deep to walk, so
- // the key must exist while the value may not.
- expect(stats).toHaveProperty("churn");
- });
-
- it("files index and file detail", async () => {
- const p = fixtureProvider([
- ["/files/detail", "file-detail"],
- ["/files", "files-index"],
- ]);
- const index: FilesIndexResponse = await p.getFilesIndex("repo-1");
- expect(index.files[0]).toHaveProperty("file_path");
- expect(index.files[0]).toHaveProperty("pagerank_pct");
- expect(typeof index.total).toBe("number");
-
- const detail: FileDetailResponse = await p.getFileDetail("repo-1", "src/flask/app.py");
- expect(detail).toHaveProperty("file_path");
- });
-
- it("hotspots page keeps the paginated envelope", async () => {
- const p = fixtureProvider([["/hotspots", "hotspots"]]);
- const page: Paginated<HotspotResponse> = await p.getHotspotsPage("repo-1", { limit: 2 });
- expect(typeof page.total).toBe("number");
- expect(page.items[0]).toHaveProperty("path");
- expect(page.items[0]).toHaveProperty("churn_percentile");
- });
-
- it("architecture graph and module graph", async () => {
- const p = fixtureProvider([
- ["/architecture", "architecture"],
- ["/module-graph", "module-graph"],
- ]);
- const arch: ArchitectureGraphResponse = await p.getArchitecture("repo-1");
- expect(Array.isArray(arch.nodes)).toBe(true);
- expect(Array.isArray(arch.edges)).toBe(true);
-
- const modules: ModuleGraphResponse = await p.getModuleGraph("repo-1");
- expect(Array.isArray(modules.nodes)).toBe(true);
- });
-
- it("decisions, dead code, search and docs map into the local shapes", async () => {
- const p = fixtureProvider([
- ["/decisions", "decisions"],
- ["/dead-code", "dead-code"],
- ["/search", "search"],
- ["/docs", "docs"],
- ]);
- const decisions = await p.listDecisions("repo-1");
- expect(decisions.length).toBeGreaterThan(0);
- expect(decisions[0]).toHaveProperty("title");
-
- const findings = await p.listDeadCode("repo-1");
- expect(findings[0]!.id).toBeTruthy();
- expect(findings[0]!.status).toBeTruthy();
-
- const results = await p.search("application factory", { repo_id: "repo-1" });
- expect(results[0]).toHaveProperty("title");
- expect(results[0]).toHaveProperty("target_path");
- expect(typeof results[0]!.page_id).toBe("string");
-
- const pages = await p.listAllPages("repo-1");
- expect(pages[0]!.id).toBeTruthy();
- expect(pages[0]!.repository_id).toBe("repo-1");
- });
-
- it("snapshot status carries the polling fields", async () => {
- const p = fixtureProvider([["/snapshots/snap-x", "snapshot-status"]]);
- const status = await p.getSnapshotStatus("snap-x");
- expect(["queued", "indexing", "ready", "failed"]).toContain(status.status);
- expect(status.short_id).toBeTruthy();
- });
-});
diff --git a/packages/api-client/src/hosted.test.ts b/packages/api-client/src/hosted.test.ts
deleted file mode 100644
index 9786f757f..000000000
--- a/packages/api-client/src/hosted.test.ts
+++ /dev/null
@@ -1,581 +0,0 @@
-import { beforeEach, describe, expect, it, vi } from "vitest";
-
-import { ApiClientError } from "./client";
-import {
- createHostedProvider,
- mapHostedDeadCodeFinding,
- mapHostedPage,
- mapHostedRepo,
- mapHostedSearchResult,
- toPageSummary,
-} from "./hosted";
-
-// ---------------------------------------------------------------------------
-// Shared wire fixtures (shape per the hosted API's /repos/mine and snapshot
-// routes; trimmed to the fields the adapter reads)
-// ---------------------------------------------------------------------------
-
-const READY_REPO = {
- repo: {
- id: "repo-1",
- canonical_url: "github.com/acme/widgets",
- owner: "acme",
- name: "widgets",
- default_branch: "main",
- latest_known_head_sha: "aaa111",
- is_public: true,
- description: "Widget factory",
- primary_language: "Python",
- stars: 42,
- last_checked_at: "2026-07-01T00:00:00Z",
- },
- active_snapshot: {
- id: "snap-1",
- short_id: "abcdef123456",
- status: "ready",
- head_sha: "bbb222",
- completed_at: "2026-06-30T00:00:00Z",
- },
- added_at: "2026-06-01T00:00:00Z",
- team_name: null,
-};
-
-const UNINDEXED_REPO = {
- repo: {
- id: "repo-2",
- canonical_url: "github.com/acme/empty",
- owner: "acme",
- name: "empty",
- default_branch: null,
- latest_known_head_sha: null,
- is_public: false,
- },
- active_snapshot: null,
- team_name: "Platform",
-};
-
-function jsonResponse(body: unknown, status = 200): Response {
- return new Response(JSON.stringify(body), {
- status,
- headers: { "Content-Type": "application/json" },
- });
-}
-
-/** A fetch stub that routes by URL substring and records every call. */
-function makeFetch(routes: Array<[string, unknown]>) {
- const calls: Array<{ url: string; init: RequestInit }> = [];
- const impl = vi.fn(async (url: string | URL | Request, init?: RequestInit) => {
- const u = String(url);
- calls.push({ url: u, init: init ?? {} });
- for (const [needle, body] of routes) {
- if (u.includes(needle)) {
- return typeof body === "string" ? new Response(body, { status: 200 }) : jsonResponse(body);
- }
- }
- return jsonResponse({ detail: `no route for ${u}` }, 404);
- });
- return { impl: impl as unknown as typeof fetch, calls };
-}
-
-function provider(routes: Array<[string, unknown]>, token: string | null = "tok-1") {
- const { impl, calls } = makeFetch(routes);
- return {
- p: createHostedProvider({ baseUrl: "https://api.example.dev", token, fetch: impl }),
- calls,
- };
-}
-
-const REPOS_ROUTE: [string, unknown] = ["/repos/mine", [READY_REPO, UNINDEXED_REPO]];
-
-// ---------------------------------------------------------------------------
-// Mapping
-// ---------------------------------------------------------------------------
-
-describe("mapHostedRepo", () => {
- it("presents a hosted repo in the local RepoResponse shape", () => {
- const mapped = mapHostedRepo(READY_REPO);
- expect(mapped).toMatchObject({
- id: "repo-1",
- name: "widgets",
- url: "https://github.com/acme/widgets",
- local_path: "",
- default_branch: "main",
- head_commit: "bbb222",
- settings: {},
- hosted: true,
- owner: "acme",
- snapshot_id: "snap-1",
- snapshot_short_id: "abcdef123456",
- snapshot_status: "ready",
- last_indexed_at: "2026-06-30T00:00:00Z",
- });
- });
-
- it("degrades cleanly for a repo with no snapshot", () => {
- const mapped = mapHostedRepo(UNINDEXED_REPO);
- expect(mapped.head_commit).toBeNull();
- expect(mapped.snapshot_id).toBeNull();
- expect(mapped.snapshot_status).toBeNull();
- expect(mapped.default_branch).toBe("main");
- expect(mapped.team_name).toBe("Platform");
- });
-});
-
-describe("mapHostedPage", () => {
- it("keeps content fields and defaults the local-DB bookkeeping", () => {
- const page = mapHostedPage(
- {
- page_id: "file_page:src/a.py",
- id: "file_page:src/a.py",
- title: "a.py",
- content: "# a",
- page_type: "file_page",
- target_path: "src/a.py",
- metadata: { onboarding_slot: "start" },
- },
- "repo-1",
- );
- expect(page.id).toBe("file_page:src/a.py");
- expect(page.repository_id).toBe("repo-1");
- expect(page.version).toBe(1);
- expect(page.freshness_status).toBe("fresh");
- expect(page.human_notes).toBeNull();
- expect(page.metadata).toEqual({ onboarding_slot: "start" });
- });
-
- it("falls back to page_id when the id alias is absent (old snapshots)", () => {
- expect(mapHostedPage({ page_id: "p1" }, "r").id).toBe("p1");
- });
-
- it("promotes the layer stamp so it survives the summary trim", () => {
- // The docs tree groups modules under their layer from this stamp and is
- // drawn from a summary listing, which drops `metadata` wholesale. Left
- // inside the blob the stamp would vanish, and every layer group with it.
- const page = mapHostedPage(
- {
- page_id: "module_page:src/api",
- page_type: "module_page",
- target_path: "src/api",
- metadata: { layer_id: "layer:api", layer_name: "API Surface" },
- },
- "repo-1",
- );
- expect(page.layer_id).toBe("layer:api");
- expect(page.layer_name).toBe("API Surface");
- expect(toPageSummary(page).layer_id).toBe("layer:api");
- });
-
- it("reports no layer rather than an empty one when nothing stamped it", () => {
- const page = mapHostedPage({ page_id: "p1", metadata: {} }, "r");
- expect(page.layer_id).toBeNull();
- expect(page.layer_name).toBeNull();
- });
-});
-
-describe("mapHostedDeadCodeFinding", () => {
- it("synthesises an id and triage defaults for artifact rows", () => {
- const f = mapHostedDeadCodeFinding({
- kind: "unused_export",
- file_path: "src/a.py",
- symbol_name: "helper",
- confidence: 0.9,
- start_line: 10,
- });
- expect(f.id).toBe("src/a.py:helper:10");
- expect(f.status).toBe("open");
- expect(f.note).toBeNull();
- expect(f.risk_factors).toEqual([]);
- });
-});
-
-describe("mapHostedSearchResult", () => {
- it("fills page_id for results that lack one", () => {
- const r = mapHostedSearchResult({ title: "t", target_path: "src/a.py", score: 0.5 });
- expect(r.page_id).toBe("");
- expect(r.search_type).toBe("keyword");
- });
-});
-
-// ---------------------------------------------------------------------------
-// Snapshot resolution
-// ---------------------------------------------------------------------------
-
-describe("snapshot resolution", () => {
- it("resolves via /repos/mine once and caches per repo", async () => {
- const { p, calls } = provider([
- REPOS_ROUTE,
- ["/health/overview", { kpis: { file_count: 1, average_health: 8 }, files: [], biomarkers: [] }],
- ]);
- await p.getHealthOverview("repo-1");
- await p.getHealthTrend("repo-1").catch(() => undefined);
- const repoListCalls = calls.filter((c) => c.url.includes("/repos/mine"));
- expect(repoListCalls).toHaveLength(1);
- expect(calls[1]!.url).toContain("/snapshots/snap-1/health/overview");
- });
-
- it("throws 404 for a repo that is not on the account", async () => {
- const { p } = provider([REPOS_ROUTE]);
- await expect(p.getHealthOverview("nope")).rejects.toMatchObject({ status: 404 });
- });
-
- it("throws 409 for a repo with no ready snapshot", async () => {
- const { p } = provider([REPOS_ROUTE]);
- await expect(p.getHealthOverview("repo-2")).rejects.toMatchObject({ status: 409 });
- });
-
- it("refresh() drops the cache so the next call re-resolves", async () => {
- const { p, calls } = provider([REPOS_ROUTE, ["/stats/highlights", {}]]);
- await p.getStatsHighlights("repo-1");
- p.refresh();
- await p.getStatsHighlights("repo-1");
- expect(calls.filter((c) => c.url.includes("/repos/mine"))).toHaveLength(2);
- });
-});
-
-// ---------------------------------------------------------------------------
-// Request wiring
-// ---------------------------------------------------------------------------
-
-describe("request wiring", () => {
- it("attaches the bearer token from a live resolver", async () => {
- const { impl, calls } = makeFetch([REPOS_ROUTE]);
- let token: string | null = "first";
- const p = createHostedProvider({
- baseUrl: "https://api.example.dev",
- token: () => token,
- fetch: impl,
- });
- await p.listRepos();
- token = "second";
- p.refresh();
- await p.listRepos();
- const auth = (i: number) => new Headers(calls[i]!.init.headers).get("Authorization");
- expect(auth(0)).toBe("Bearer first");
- expect(auth(1)).toBe("Bearer second");
- });
-
- it("stays anonymous without a token (public repo reads)", async () => {
- const { impl, calls } = makeFetch([REPOS_ROUTE]);
- const p = createHostedProvider({ baseUrl: "https://api.example.dev", token: null, fetch: impl });
- await p.listRepos();
- expect(new Headers(calls[0]!.init.headers).get("Authorization")).toBeNull();
- });
-
- it("passes query params through on re-addressed routes", async () => {
- const { p, calls } = provider([REPOS_ROUTE, ["/health/files", []]]);
- const res = await p.listHealthFiles("repo-1", { limit: 10, sort: "score", search: "app" });
- const url = calls.at(-1)!.url;
- expect(url).toContain("/snapshots/snap-1/health/files");
- expect(url).toContain("sort=score");
- expect(url).toContain("q=app");
- expect(res).toMatchObject({ total: 0, offset: 0, limit: 10, files: [] });
- });
-
- it("keeps the server's total when the route returns the envelope", async () => {
- // The bare-array era could only report the page size, so a 3k-file repo
- // capped at 500 reported 500 files.
- const row = { file_path: "a.ts", score: 5, nloc: 10 };
- const { p } = provider([
- REPOS_ROUTE,
- ["/health/files", { total: 3013, offset: 0, limit: 2000, files: [row] }],
- ]);
- const res = await p.listHealthFiles("repo-1", { limit: 10 });
- expect(res.total).toBe(3013);
- expect(res.files).toHaveLength(1);
- });
-
- it("still reads an older deployment's bare array", async () => {
- const rows = [
- { file_path: "a.ts", score: 5, nloc: 10 },
- { file_path: "b.ts", score: 6, nloc: 20 },
- ];
- const { p } = provider([REPOS_ROUTE, ["/health/files", rows]]);
- const res = await p.listHealthFiles("repo-1", { limit: 10 });
- expect(res.total).toBe(2);
- expect(res.files).toHaveLength(2);
- });
-
- it("recounts the total when it narrows the set client-side", async () => {
- // A module filter is applied here, not by the server, so the server's
- // total would overstate what the caller actually receives.
- const row = (file_path: string) => ({ file_path, score: 5, nloc: 10 });
- const { p } = provider([
- REPOS_ROUTE,
- [
- "/health/files",
- { total: 3013, offset: 0, limit: 2000, files: [row("src/a.ts"), row("web/b.ts")] },
- ],
- ]);
- const res = await p.listHealthFiles("repo-1", { limit: 10, module: "src/" });
- expect(res.total).toBe(1);
- expect(res.files.map((f) => f.file_path)).toEqual(["src/a.ts"]);
- });
-
- it("surfaces API errors as ApiClientError with the detail", async () => {
- const { impl } = makeFetch([REPOS_ROUTE]);
- const p = createHostedProvider({ baseUrl: "https://api.example.dev", fetch: impl });
- await p.listRepos();
- // No route registered for health/overview: stub returns a 404 body.
- await expect(p.getHealthOverview("repo-1")).rejects.toBeInstanceOf(ApiClientError);
- });
-
- it("passes bounded performance and refactoring paging through snapshot routes", async () => {
- const envelope = { items: [], total: 0, has_more: false, next_offset: null };
- const { p, calls } = provider([
- REPOS_ROUTE,
- ["/refactoring/plan-1", { id: "plan-1", refactoring_type: "performance_fix" }],
- [
- "/refactoring/targets/page",
- { ...envelope, summary: { total: 0, by_type: [] }, structural_leads: [] },
- ],
- ["/health/performance-opportunities/opp-1/findings", envelope],
- [
- "/health/performance-opportunities",
- {
- ...envelope,
- summary: { status: "current", total: 0, with_plan_total: 0 },
- },
- ],
- ]);
-
- await p.getRefactoringPlansPage("repo-1", {
- refactoringType: "performance_fix",
- confidence: "high,medium",
- sort: "canonical",
- limit: 20,
- offset: 40,
- });
- await p.getRefactoringPlan("repo-1", "plan-1");
- await p.getPerformanceOpportunities("repo-1", { context: "test", limit: 20 });
- await p.getPerformanceOpportunityFindings("repo-1", "opp-1", { limit: 50 });
-
- expect(calls.at(-4)!.url).toContain("refactoring_type=performance_fix");
- expect(calls.at(-4)!.url).toContain("offset=40");
- expect(calls.at(-3)!.url).toContain("refactoring/plan-1");
- expect(calls.at(-2)!.url).toContain("context=test");
- expect(calls.at(-1)!.url).toContain("performance-opportunities/opp-1/findings");
- });
-});
-
-// ---------------------------------------------------------------------------
-// Docs
-// ---------------------------------------------------------------------------
-
-const DOCS_BODY = {
- available: true,
- docs_status: "ready",
- pages_ready: 2,
- pages_total: 2,
- pages: [
- { id: "overview", page_id: "overview", page_type: "overview", title: "Overview" },
- { id: "file_page:a", page_id: "file_page:a", page_type: "file_page", title: "a" },
- ],
-};
-
-describe("docs", () => {
- it("maps and caches the docs list per snapshot", async () => {
- const { p, calls } = provider([REPOS_ROUTE, ["/docs", DOCS_BODY]]);
- const all = await p.listAllPages("repo-1");
- await p.listAllPages("repo-1");
- expect(all).toHaveLength(2);
- expect(all[0]!.repository_id).toBe("repo-1");
- expect(calls.filter((c) => c.url.includes("/docs"))).toHaveLength(1);
- });
-
- it("serves summaries with the heavy fields actually removed", async () => {
- const { p } = provider([
- REPOS_ROUTE,
- [
- "/docs",
- {
- ...DOCS_BODY,
- pages: [
- {
- id: "overview",
- page_type: "overview",
- title: "Overview",
- content: "a body",
- metadata: { layer_order: ["ui"] },
- },
- ],
- },
- ],
- ]);
-
- const [summary] = await p.listAllPages("repo-1", { fields: "summary" });
-
- expect(summary).not.toHaveProperty("content");
- expect(summary).not.toHaveProperty("metadata");
- expect(summary!.title).toBe("Overview");
- expect(summary!.content_chars).toBe("a body".length);
- });
-
- it("listPages filters by page_type and slices", async () => {
- const { p } = provider([REPOS_ROUTE, ["/docs", DOCS_BODY]]);
- const filtered = await p.listPages("repo-1", { page_type: "file_page" });
- expect(filtered.map((pg) => pg.id)).toEqual(["file_page:a"]);
- const sliced = await p.listPages("repo-1", { limit: 1 });
- expect(sliced).toHaveLength(1);
- });
-
- it("getPageById finds a page and 404s on a miss", async () => {
- const { p } = provider([REPOS_ROUTE, ["/docs", DOCS_BODY]]);
- const page = await p.getPageById("overview", "repo-1");
- expect(page.title).toBe("Overview");
- await expect(p.getPageById("missing", "repo-1")).rejects.toMatchObject({ status: 404 });
- });
-
- it("getDocsStatus exposes the generation-progress fields", async () => {
- const { p } = provider([REPOS_ROUTE, ["/docs", DOCS_BODY]]);
- expect(await p.getDocsStatus("repo-1")).toEqual({
- available: true,
- docs_status: "ready",
- pages_ready: 2,
- pages_total: 2,
- });
- });
-});
-
-// ---------------------------------------------------------------------------
-// Envelope unwrapping
-// ---------------------------------------------------------------------------
-
-describe("envelope unwrapping", () => {
- it("listDecisions unwraps the hosted envelope", async () => {
- const { p } = provider([
- REPOS_ROUTE,
- ["/decisions", { total_found: 1, decisions: [{ title: "Use X" }], by_source: {} }],
- ]);
- const decisions = await p.listDecisions("repo-1");
- expect(decisions).toEqual([{ title: "Use X" }]);
- });
-
- it("listDeadCode unwraps and filters client-side", async () => {
- const { p } = provider([
- REPOS_ROUTE,
- [
- "/dead-code",
- {
- total_findings: 3,
- deletable_lines: 30,
- findings: [
- { kind: "unused_export", file_path: "a.py", confidence: 0.9, safe_to_delete: true },
- { kind: "unused_export", file_path: "b.py", confidence: 0.4, safe_to_delete: false },
- { kind: "unreachable", file_path: "c.py", confidence: 0.95, safe_to_delete: true },
- ],
- },
- ],
- ]);
- const safe = await p.listDeadCode("repo-1", { kind: "unused_export", min_confidence: 0.5 });
- expect(safe.map((f) => f.file_path)).toEqual(["a.py"]);
- });
-
- it("search posts to the snapshot route and maps results", async () => {
- const { p, calls } = provider([
- REPOS_ROUTE,
- ["/search", { results: [{ title: "hit", target_path: "a.py", score: 1, search_type: "semantic" }] }],
- ]);
- const results = await p.search("widgets", { repo_id: "repo-1", limit: 5 });
- expect(results[0]).toMatchObject({ title: "hit", page_id: "", search_type: "semantic" });
- const call = calls.at(-1)!;
- expect(call.url).toContain("/snapshots/snap-1/search");
- expect(JSON.parse(String(call.init.body))).toEqual({ query: "widgets", limit: 5 });
- });
-
- it("search without repo_id is rejected", async () => {
- const { p } = provider([REPOS_ROUTE]);
- await expect(p.search("q")).rejects.toMatchObject({ status: 400 });
- });
-});
-
-// ---------------------------------------------------------------------------
-// Indexing lifecycle
-// ---------------------------------------------------------------------------
-
-describe("indexing lifecycle", () => {
- it("triggerReindex posts to the repo route with the docs flag", async () => {
- const { p, calls } = provider([
- ["/repos/repo-1/reindex", { snapshot_id: "snap-2", short_id: "s2", status: "queued", cached: false }],
- ]);
- const res = await p.triggerReindex("repo-1", { generate_docs: true });
- expect(res.status).toBe("queued");
- const call = calls.at(-1)!;
- expect(call.init.method).toBe("POST");
- expect(JSON.parse(String(call.init.body))).toEqual({ generate_docs: true });
- });
-
- it("getSnapshotStatus polls the snapshot row", async () => {
- const { p, calls } = provider([["/snapshots/snap-2", { id: "snap-2", status: "indexing" }]]);
- const status = await p.getSnapshotStatus("snap-2");
- expect(status.status).toBe("indexing");
- expect(calls[0]!.url).toContain("/snapshots/snap-2");
- });
-});
-
-// ---------------------------------------------------------------------------
-// Coupling normalization
-// ---------------------------------------------------------------------------
-
-describe("getCoupling", () => {
- it("fills in nodes/edges a snapshot artifact omitted", async () => {
- // A snapshot written before the coupling analyzer ran has no `nodes`/`edges`
- // key at all. `CouplingGraphResponse` declares them required, so an
- // unnormalized pass-through put `undefined` where the explorer iterates and
- // threw during render, blanking the whole architecture page.
- const { p } = provider([REPOS_ROUTE, ["/coupling", { total_edges: 0 }]]);
- const graph = await p.getCoupling("repo-1");
- expect(graph.nodes).toEqual([]);
- expect(graph.edges).toEqual([]);
- expect(graph.total_edges).toBe(0);
- });
-
- it("falls back to the drawn edge count when total_edges is absent", async () => {
- const edges = [{ source: "a.rs", target: "b.rs", strength: 3, last_co_change: null }];
- const { p } = provider([REPOS_ROUTE, ["/coupling", { edges }]]);
- const graph = await p.getCoupling("repo-1");
- expect(graph.edges).toHaveLength(1);
- expect(graph.total_edges).toBe(1);
- });
-
- it("passes a well-formed payload through unchanged", async () => {
- const body = {
- nodes: [{ file_path: "a.rs", module: "src", score: 7, nloc: 100 }],
- edges: [
- {
- source: "a.rs",
- target: "b.rs",
- strength: 3,
- last_co_change: "2026-06-01",
- support: 11,
- confidence_ab: 0.9,
- confidence_ba: 0.1,
- structural: "unexplained",
- dependency_kind: null,
- },
- ],
- total_edges: 9,
- coupled_files: 6,
- total_files: 20,
- };
- const { p } = provider([REPOS_ROUTE, ["/coupling", body]]);
- expect(await p.getCoupling("repo-1")).toEqual(body);
- });
-
- it("defaults the support fields a pre-support snapshot omits", async () => {
- // The wire type declares them required; a snapshot written before they
- // existed has neither, and the table reads them straight into a cell.
- const wire = [{ source: "a.rs", target: "b.rs", strength: 3, last_co_change: null }];
- const { p } = provider([REPOS_ROUTE, ["/coupling", { edges: wire, total_edges: 1 }]]);
- const { edges, coupled_files, total_files } = await p.getCoupling("repo-1");
- expect(edges[0]).toMatchObject({
- support: 0,
- confidence_ab: null,
- confidence_ba: null,
- structural: null,
- dependency_kind: null,
- });
- // Zero reads as "not measured", which the scope line renders by omitting
- // the denominator rather than claiming nothing is coupled.
- expect({ coupled_files, total_files }).toEqual({ coupled_files: 0, total_files: 0 });
- });
-});
diff --git a/packages/api-client/src/hosted.ts b/packages/api-client/src/hosted.ts
deleted file mode 100644
index 4596fa028..000000000
--- a/packages/api-client/src/hosted.ts
+++ /dev/null
@@ -1,983 +0,0 @@
-/**
- * Hosted-platform provider: the same typed read surface as the per-domain
- * modules in this package, addressed at the hosted repowise API instead of a
- * local server.
- *
- * The hosted API serves the same artifact JSON the local pipeline produces,
- * but reads are snapshot-addressed (`/snapshots/{id}/...`) where the local
- * server is repo-addressed (`/api/repos/{id}/...`). The provider bridges
- * that: every method takes the same arguments as its local counterpart and
- * resolves the repo's latest ready snapshot internally (resolved once per
- * repo and cached; `refresh()` clears the cache after a reindex).
- *
- * Unlike `configureApiClient`, which sets module-global state, this is an
- * instance factory: a host app can hold a hosted provider per account next
- * to the local singleton client and route per repo.
- */
-
-import type { ArchitectureView, C4L1, C4L2, C4L3 } from "@repowise-dev/ui/c4";
-import type { CouplingEdge, CouplingGraphResponse } from "@repowise-dev/types/coupling";
-import type { FileDetailResponse, FilesIndexResponse } from "@repowise-dev/types/files";
-import type {
- ChurnComplexityResponse,
- HealthCoverageResponse,
- HealthFileBreakdownResponse,
- HealthFilesQuery,
- HealthFilesResponse,
- HealthFinding,
- HealthOverviewResponse,
- HealthTrendResponse,
- HealthWorkQueueQuery,
- HealthWorkQueueResponse,
-} from "@repowise-dev/types/health";
-import type { OverviewSummaryResponse } from "@repowise-dev/types/overview";
-import type {
- PerformanceOpportunityPage,
- PerformanceOpportunityQuery,
-} from "@repowise-dev/types/health";
-import type {
- RefactoringPlan,
- RefactoringPlanPage,
- RefactoringTargets,
-} from "@repowise-dev/types/refactoring";
-import type { StatsHighlights } from "@repowise-dev/types/stats";
-import type { SymbolDetailResponse } from "@repowise-dev/types/symbols";
-import { ApiClientError } from "./client";
-import type { ModuleHealthSortKey } from "./modules";
-import type { RefactoringPageParams, RefactoringTargetsParams } from "./refactoring";
-import type {
- ArchitectureGraphResponse,
- CommunitySliceResponse,
- DeadCodeFindingResponse,
- DecisionRecordResponse,
- ExecutionFlowsResponse,
- GitSummaryResponse,
- HotspotResponse,
- ModuleGraphResponse,
- ModuleHealthDetail,
- ModuleHealthSummary,
- Paginated,
- PageResponse,
- PageSummary,
- RepoResponse,
- SearchResultResponse,
-} from "./types";
-import type { PageFields } from "./pages";
-
-// ---------------------------------------------------------------------------
-// Config + hosted-only response types
-// ---------------------------------------------------------------------------
-
-export interface HostedProviderConfig {
- /** Absolute origin of the hosted API, e.g. "https://api.repowise.dev". */
- baseUrl: string;
- /**
- * Bearer token: an OAuth access token or an rw_live_ API key. May be a
- * resolver called fresh on every request (same convention as
- * `configureApiClient`). Reads on public repos work without one.
- */
- token?: string | null | (() => string | null);
- fetch?: typeof fetch;
-}
-
-export type HostedSnapshotState = "queued" | "indexing" | "ready" | "failed";
-
-/** Snapshot row served by GET /snapshots/{id}; the reindex polling target. */
-export interface HostedSnapshotStatus {
- id: string;
- short_id: string;
- repo_id: string;
- head_sha: string | null;
- status: HostedSnapshotState;
- error_message: string | null;
- file_count: number | null;
- line_count: number | null;
- ref: string | null;
- created_at: string | null;
- completed_at: string | null;
-}
-
-export interface HostedReindexResponse {
- snapshot_id: string;
- short_id: string;
- status: HostedSnapshotState;
- /** True when the head commit was already indexed and no new run started. */
- cached: boolean;
-}
-
-/**
- * A hosted repo presented in the local `RepoResponse` shape (so repo-list
- * components render it unchanged) plus hosted-only context. `local_path` is
- * always "" and `hosted` is the discriminant.
- */
-export interface HostedRepoResponse extends RepoResponse {
- hosted: true;
- owner: string;
- is_public: boolean;
- description: string | null;
- primary_language: string | null;
- stars: number | null;
- /** Team that shares this repo with the account, if any. */
- team_name: string | null;
- snapshot_id: string | null;
- snapshot_short_id: string | null;
- snapshot_status: HostedSnapshotState | null;
- last_indexed_at: string | null;
-}
-
-/** Docs payload with the hosted generation-progress fields. */
-export interface HostedDocsStatus {
- available: boolean;
- docs_status: string | null;
- pages_ready: number;
- pages_total: number | null;
-}
-
-// Wire shapes of the hosted endpoints the provider maps (not re-exported).
-
-interface WireSnapshot {
- id?: string;
- short_id?: string;
- status?: string;
- head_sha?: string | null;
- completed_at?: string | null;
-}
-
-interface WireUserRepo {
- repo: {
- id: string;
- canonical_url: string;
- owner: string;
- name: string;
- default_branch: string | null;
- latest_known_head_sha: string | null;
- is_public: boolean;
- description?: string | null;
- primary_language?: string | null;
- stars?: number | null;
- last_checked_at?: string | null;
- };
- active_snapshot: WireSnapshot | null;
- added_at?: string | null;
- team_name?: string | null;
-}
-
-interface WireDocs extends HostedDocsStatus {
- pages: Array<Record<string, unknown>>;
-}
-
-interface WireDecisions {
- total_found: number;
- decisions: Array<Record<string, unknown>>;
- by_source: Record<string, number>;
-}
-
-interface WireDeadCode {
- total_findings: number;
- deletable_lines: number;
- findings: Array<Record<string, unknown>>;
-}
-
-interface WireSearch {
- results: Array<Record<string, unknown>>;
-}
-
-interface WireFindings {
- items: HealthFinding[];
- total: number;
-}
-
-interface WireTrend {
- points: Array<{
- taken_at: string;
- hotspot_health: number;
- average_health: number;
- worst_performer_path?: string | null;
- worst_performer_score?: number | null;
- }>;
- declining: boolean;
- predicted_decline: boolean;
-}
-
-const SEVERITY_ORDER: Record<string, number> = { low: 0, medium: 1, high: 2, critical: 3 };
-
-interface WireHealthOverview {
- kpis: Record<string, unknown> & {
- file_count?: number;
- average_health?: number;
- worst_performer_path?: string | null;
- worst_performer_score?: number | null;
- };
- files: HealthOverviewResponse["files"];
- /** Top finding rows (the hosted counterpart of the local `top_findings`). */
- biomarkers: HealthFinding[];
- modules?: HealthOverviewResponse["modules"];
- defect_accuracy?: HealthOverviewResponse["defect_accuracy"];
- meta?: HealthOverviewResponse["meta"];
-}
-
-interface WireFilesIndex {
- files: FilesIndexResponse["files"];
- language_counts: Record<string, number>;
- totals: { files?: number; loc?: number };
-}
-
-/**
- * Coupling as it arrives, not as `CouplingGraphResponse` promises: a snapshot
- * written before the coupling analyzer ran omits `nodes`/`edges` entirely, and
- * one written before support/confidence existed omits those per edge.
- */
-interface WireCoupling {
- nodes?: CouplingGraphResponse["nodes"];
- edges?: Partial<CouplingEdge>[];
- total_edges?: number;
- coupled_files?: number;
- total_files?: number;
-}
-
-// ---------------------------------------------------------------------------
-// Mapping helpers (exported for tests)
-// ---------------------------------------------------------------------------
-
-export function mapHostedRepo(item: WireUserRepo): HostedRepoResponse {
- const { repo, active_snapshot: snap } = item;
- return {
- id: repo.id,
- name: repo.name,
- url: `https://${repo.canonical_url}`,
- local_path: "",
- default_branch: repo.default_branch ?? "main",
- head_commit: snap?.head_sha ?? repo.latest_known_head_sha ?? null,
- settings: {},
- created_at: item.added_at ?? "",
- updated_at: repo.last_checked_at ?? item.added_at ?? "",
- hosted: true,
- owner: repo.owner,
- is_public: repo.is_public,
- description: repo.description ?? null,
- primary_language: repo.primary_language ?? null,
- stars: repo.stars ?? null,
- team_name: item.team_name ?? null,
- snapshot_id: snap?.id ?? null,
- snapshot_short_id: snap?.short_id ?? null,
- snapshot_status: (snap?.status as HostedSnapshotState | undefined) ?? null,
- last_indexed_at: snap?.completed_at ?? null,
- };
-}
-
-/**
- * A pages.json entry into the local `PageResponse` shape. The artifact
- * carries the content fields; the local-DB bookkeeping fields (token counts,
- * versioning) do not exist on hosted and get neutral defaults.
- */
-export function mapHostedPage(raw: Record<string, unknown>, repoId: string): PageResponse {
- const str = (k: string): string => (typeof raw[k] === "string" ? (raw[k] as string) : "");
- const num = (k: string, fallback = 0): number =>
- typeof raw[k] === "number" ? (raw[k] as number) : fallback;
- const content = str("content");
- const metadata = (raw.metadata as Record<string, unknown> | undefined) ?? {};
- // The layer stamp gets a field of its own because `toPageSummary` drops the
- // whole metadata blob, and the docs tree groups pages by this stamp off a
- // summary listing. Blank reads as `null`, never "", so "no layer claimed
- // this page" cannot be mistaken for a layer whose name is empty.
- const stamp = (key: string): string | null => {
- const value = metadata[key];
- return typeof value === "string" && value ? value : null;
- };
- return {
- id: str("id") || str("page_id"),
- repository_id: repoId,
- page_type: str("page_type"),
- title: str("title"),
- content,
- content_chars: content.length,
- target_path: str("target_path"),
- source_hash: str("source_hash"),
- model_name: str("model_name"),
- provider_name: str("provider_name"),
- input_tokens: num("input_tokens"),
- output_tokens: num("output_tokens"),
- cached_tokens: num("cached_tokens"),
- generation_level: num("generation_level"),
- version: num("version", 1),
- confidence: num("confidence", 1),
- freshness_status: str("freshness_status") || "fresh",
- metadata,
- layer_id: stamp("layer_id"),
- layer_name: stamp("layer_name"),
- human_notes: null,
- created_at: str("created_at"),
- updated_at: str("updated_at") || str("created_at"),
- };
-}
-
-/** Drop a page's two heavy fields, keeping the rest byte-identical. */
-export function toPageSummary(page: PageResponse): PageSummary {
- const { content: _content, metadata: _metadata, ...summary } = page;
- return summary;
-}
-
-/** A dead_code.json finding into the local finding shape (artifact rows lack
- * the local-DB triage fields, which default to an open, note-less finding). */
-export function mapHostedDeadCodeFinding(raw: Record<string, unknown>): DeadCodeFindingResponse {
- const partial = raw as Partial<DeadCodeFindingResponse>;
- return {
- id:
- partial.id ??
- `${partial.file_path ?? ""}:${partial.symbol_name ?? ""}:${partial.start_line ?? 0}`,
- kind: partial.kind ?? "",
- file_path: partial.file_path ?? "",
- symbol_name: partial.symbol_name ?? null,
- symbol_kind: partial.symbol_kind ?? null,
- confidence: partial.confidence ?? 0,
- reason: partial.reason ?? "",
- lines: partial.lines ?? 0,
- start_line: partial.start_line ?? null,
- end_line: partial.end_line ?? null,
- safe_to_delete: partial.safe_to_delete ?? false,
- risk_factors: partial.risk_factors ?? [],
- evidence: partial.evidence ?? [],
- primary_owner: partial.primary_owner ?? null,
- status: partial.status ?? "open",
- note: partial.note ?? null,
- // Artifacts written before these were surfaced carry neither; a missing
- // date must not read as "never touched", so it stays null.
- last_commit_at: partial.last_commit_at ?? null,
- commit_count_90d: partial.commit_count_90d ?? 0,
- };
-}
-
-export function mapHostedSearchResult(raw: Record<string, unknown>): SearchResultResponse {
- const partial = raw as Partial<SearchResultResponse>;
- return {
- page_id: partial.page_id ?? "",
- title: partial.title ?? "",
- page_type: partial.page_type ?? "",
- target_path: partial.target_path ?? "",
- score: partial.score ?? 0,
- snippet: partial.snippet ?? "",
- search_type: partial.search_type ?? "keyword",
- };
-}
-
-// ---------------------------------------------------------------------------
-// Provider
-// ---------------------------------------------------------------------------
-
-type QueryParams = Record<string, string | number | boolean | undefined>;
-
-export interface HostedProvider {
- /** Personal + team repos of the signed-in account, in RepoResponse shape. */
- listRepos(): Promise<HostedRepoResponse[]>;
- /** Drops the cached repo list and snapshot ids (e.g. after a reindex). */
- refresh(): void;
-
- // Overview / stats / health (identical shapes, re-addressed)
- getOverviewSummary(repoId: string): Promise<OverviewSummaryResponse>;
- getStatsHighlights(repoId: string): Promise<StatsHighlights>;
- getHealthOverview(repoId: string, limit?: number): Promise<HealthOverviewResponse>;
- listHealthFindings(
- repoId: string,
- opts?: {
- biomarker_type?: string;
- file_path?: string;
- min_severity?: string;
- dimension?: string;
- limit?: number;
- },
- ): Promise<HealthFinding[]>;
- listHealthFiles(repoId: string, opts?: HealthFilesQuery): Promise<HealthFilesResponse>;
- getHealthFileBreakdown(repoId: string, filePath: string): Promise<HealthFileBreakdownResponse>;
- getHealthTrend(repoId: string, limit?: number): Promise<HealthTrendResponse>;
- getHealthCoverage(
- repoId: string,
- opts?: { file_path?: string; limit?: number },
- ): Promise<HealthCoverageResponse>;
- getHealthWorkQueue(
- repoId: string,
- opts?: HealthWorkQueueQuery,
- ): Promise<HealthWorkQueueResponse>;
- /** @deprecated Use getHealthWorkQueue. */
- getRefactoringTargets(
- repoId: string,
- opts?: HealthWorkQueueQuery,
- ): Promise<HealthWorkQueueResponse>;
- getRefactoringPlans(
- repoId: string,
- opts?: RefactoringTargetsParams,
- ): Promise<RefactoringTargets>;
- getRefactoringPlansPage(
- repoId: string,
- opts?: RefactoringPageParams,
- ): Promise<RefactoringPlanPage>;
- getRefactoringPlan(repoId: string, planId: string): Promise<RefactoringPlan>;
- getPerformanceOpportunities(
- repoId: string,
- opts?: PerformanceOpportunityQuery,
- ): Promise<PerformanceOpportunityPage>;
- getPerformanceOpportunityFindings(
- repoId: string,
- opportunityId: string,
- opts?: { limit?: number; offset?: number },
- ): Promise<import("@repowise-dev/types").Paginated<HealthFinding>>;
- getChurnComplexity(repoId: string, opts?: { limit?: number }): Promise<ChurnComplexityResponse>;
-
- // Modules
- listModuleHealth(
- repoId: string,
- options?: { sort?: ModuleHealthSortKey; limit?: number; offset?: number },
- ): Promise<Paginated<ModuleHealthSummary>>;
- getModuleHealth(repoId: string, modulePath: string): Promise<ModuleHealthDetail>;
-
- // Architecture
- getC4L1(repoId: string): Promise<C4L1>;
- getC4L2(repoId: string): Promise<C4L2>;
- getC4L3(repoId: string, containerId: string): Promise<C4L3>;
- getC4Mermaid(repoId: string, level: 1 | 2 | 3, containerId?: string | null): Promise<string>;
- getArchitectureView(repoId: string, includeSymbols?: boolean): Promise<ArchitectureView>;
- getArchitecture(repoId: string, minMembers?: number): Promise<ArchitectureGraphResponse>;
- getCommunitySlice(repoId: string, communityId: number): Promise<CommunitySliceResponse>;
- getModuleGraph(repoId: string): Promise<ModuleGraphResponse>;
- getExecutionFlows(
- repoId: string,
- params?: { top_n?: number; max_depth?: number; entry_point?: string },
- ): Promise<ExecutionFlowsResponse>;
- getCoupling(repoId: string, opts?: { limit?: number }): Promise<CouplingGraphResponse>;
-
- // Files / symbols
- getFilesIndex(repoId: string): Promise<FilesIndexResponse>;
- getFileDetail(repoId: string, filePath: string): Promise<FileDetailResponse>;
- getSymbolDetail(repoId: string, symbolId: string): Promise<SymbolDetailResponse>;
-
- // Docs
- getDocsStatus(repoId: string): Promise<HostedDocsStatus>;
- listPages(
- repoId: string,
- opts?: { page_type?: string; limit?: number; offset?: number },
- ): Promise<PageResponse[]>;
- listAllPages(
- repoId: string,
- opts: { page_type?: string; fields: "summary" },
- ): Promise<PageSummary[]>;
- listAllPages(
- repoId: string,
- opts?: { page_type?: string; fields?: "full" },
- ): Promise<PageResponse[]>;
- getPageById(pageId: string, repoId?: string): Promise<PageResponse>;
-
- // Decisions / risk / dead code
- listDecisions(repoId: string, opts?: { limit?: number }): Promise<DecisionRecordResponse[]>;
- listDeadCode(
- repoId: string,
- opts?: {
- kind?: string;
- min_confidence?: number;
- status?: string;
- safe_only?: boolean;
- limit?: number;
- },
- ): Promise<DeadCodeFindingResponse[]>;
- getHotspotsPage(
- repoId: string,
- options?: { limit?: number; offset?: number },
- ): Promise<Paginated<HotspotResponse>>;
- getHotspots(repoId: string, limit?: number): Promise<HotspotResponse[]>;
- getCoChanges(
- repoId: string,
- filePath: string,
- minCount?: number,
- ): Promise<{
- file_path: string;
- co_change_partners: Array<{ file_path: string; co_change_count: number }>;
- total?: number;
- }>;
- getGitSummary(repoId: string, topOwnersLimit?: number): Promise<GitSummaryResponse>;
-
- // Search
- search(
- query: string,
- opts?: { search_type?: "semantic" | "fulltext"; limit?: number; repo_id?: string },
- ): Promise<SearchResultResponse[]>;
-
- // Indexing lifecycle
- triggerReindex(
- repoId: string,
- opts?: { generate_docs?: boolean; docs_file_percentage?: number },
- ): Promise<HostedReindexResponse>;
- getSnapshotStatus(snapshotId: string): Promise<HostedSnapshotStatus>;
-}
-
-export function createHostedProvider(config: HostedProviderConfig): HostedProvider {
- const baseUrl = config.baseUrl.replace(/\/+$/, "");
-
- function resolveToken(): string | null {
- const { token } = config;
- if (typeof token === "function") return token();
- return token ?? null;
- }
-
- function buildUrl(path: string, params?: QueryParams): string {
- const url = new URL(`${baseUrl}${path}`);
- if (params) {
- for (const [k, v] of Object.entries(params)) {
- if (v !== undefined && v !== null) url.searchParams.set(k, String(v));
- }
- }
- return url.toString();
- }
-
- function headers(): Headers {
- const h = new Headers({ "Content-Type": "application/json" });
- const token = resolveToken();
- if (token) h.set("Authorization", `Bearer ${token}`);
- return h;
- }
-
- async function handle<T>(res: Response): Promise<T> {
- if (!res.ok) {
- let detail = res.statusText;
- try {
- const body = (await res.json()) as { detail?: unknown };
- if (typeof body.detail === "string") detail = body.detail;
- else if (body.detail !== undefined) detail = JSON.stringify(body.detail);
- } catch {
- // response body is not JSON
- }
- throw new ApiClientError(res.status, detail);
- }
- return res.json() as Promise<T>;
- }
-
- async function get<T>(path: string, params?: QueryParams): Promise<T> {
- const res = await (config.fetch ?? fetch)(buildUrl(path, params), {
- method: "GET",
- headers: headers(),
- });
- return handle<T>(res);
- }
-
- async function getText(path: string, params?: QueryParams): Promise<string> {
- const res = await (config.fetch ?? fetch)(buildUrl(path, params), {
- method: "GET",
- headers: headers(),
- });
- if (!res.ok) throw new ApiClientError(res.status, res.statusText);
- return res.text();
- }
-
- async function post<T>(path: string, body?: unknown): Promise<T> {
- const res = await (config.fetch ?? fetch)(buildUrl(path), {
- method: "POST",
- headers: headers(),
- ...(body !== undefined ? { body: JSON.stringify(body) } : {}),
- });
- return handle<T>(res);
- }
-
- // Repo handle -> snapshot id, resolved from the repo list and cached for
- // the provider's lifetime (a snapshot's content is immutable; a reindex
- // mints a new id, surfaced via refresh()).
- let repos: HostedRepoResponse[] | null = null;
- let reposInFlight: Promise<HostedRepoResponse[]> | null = null;
- const snapshotByRepo = new Map<string, string | null>();
- const pagesBySnapshot = new Map<string, PageResponse[]>();
-
- function listRepos(): Promise<HostedRepoResponse[]> {
- // Single-flight: concurrent calls (e.g. parallel dashboard requests all
- // resolving their snapshot) share one /repos/mine round trip.
- if (reposInFlight) return reposInFlight;
- reposInFlight = (async () => {
- try {
- const items = await get<WireUserRepo[]>("/repos/mine");
- repos = items.map(mapHostedRepo);
- for (const r of repos) {
- snapshotByRepo.set(r.id, r.snapshot_status === "ready" ? r.snapshot_id : null);
- }
- return repos;
- } finally {
- reposInFlight = null;
- }
- })();
- return reposInFlight;
- }
-
- async function snapshot(repoId: string): Promise<string> {
- if (!snapshotByRepo.has(repoId)) await listRepos();
- if (!snapshotByRepo.has(repoId)) {
- throw new ApiClientError(404, `Repository ${repoId} is not on your hosted account`);
- }
- const sid = snapshotByRepo.get(repoId);
- if (!sid) {
- throw new ApiClientError(409, "This repository has no ready hosted snapshot yet");
- }
- return sid;
- }
-
- async function snapGet<T>(repoId: string, suffix: string, params?: QueryParams): Promise<T> {
- return get<T>(`/snapshots/${await snapshot(repoId)}${suffix}`, params);
- }
-
- async function getDocs(repoId: string): Promise<WireDocs> {
- return snapGet<WireDocs>(repoId, "/docs");
- }
-
- async function loadPages(repoId: string): Promise<PageResponse[]> {
- const sid = await snapshot(repoId);
- const cached = pagesBySnapshot.get(sid);
- if (cached) return cached;
- const docs = await getDocs(repoId);
- const mapped = (docs.pages ?? []).map((p) => mapHostedPage(p, repoId));
- pagesBySnapshot.set(sid, mapped);
- return mapped;
- }
-
- // Declared out here (rather than inline in the returned object) so it can
- // carry the same overloads the interface does — an object-literal method
- // can't.
- async function listAllPages(
- repoId: string,
- opts: { page_type?: string; fields: "summary" },
- ): Promise<PageSummary[]>;
- async function listAllPages(
- repoId: string,
- opts?: { page_type?: string; fields?: "full" },
- ): Promise<PageResponse[]>;
- async function listAllPages(
- repoId: string,
- opts?: { page_type?: string; fields?: PageFields },
- ): Promise<PageSummary[]> {
- const pages = await loadPages(repoId);
- const scoped = opts?.page_type
- ? pages.filter((p) => p.page_type === opts.page_type)
- : pages;
- // Hosted serves its whole docs artifact in one cached call, so `summary`
- // saves it no round trip. It still honours the contract: callers get rows
- // with no `content`/`metadata`, so a component typed against the summary
- // shape can't quietly read a body a leaner backend wouldn't have sent.
- return opts?.fields === "summary" ? scoped.map(toPageSummary) : scoped;
- }
-
- return {
- listRepos,
- refresh(): void {
- repos = null;
- snapshotByRepo.clear();
- pagesBySnapshot.clear();
- },
-
- getOverviewSummary: (repoId) => snapGet(repoId, "/overview-summary"),
- getStatsHighlights: (repoId) => snapGet(repoId, "/stats/highlights"),
- async getHealthOverview(repoId, limit = 25): Promise<HealthOverviewResponse> {
- // Hosted splits what the local route serves in one payload: the KPI
- // block is named differently, the top finding rows live under
- // `biomarkers`, the distribution has its own route, and the open
- // finding count only exists as the findings-list total. Compose them.
- const [overview, distribution, findingsPage] = await Promise.all([
- snapGet<WireHealthOverview>(repoId, "/health/overview", { limit }),
- snapGet<HealthOverviewResponse["distribution"]>(repoId, "/health/distribution").catch(
- () => null,
- ),
- snapGet<WireFindings>(repoId, "/health/findings", { limit: 1 }).catch(() => null),
- ]);
- return {
- summary: {
- ...overview.kpis,
- file_count: overview.kpis.file_count ?? 0,
- average_health: overview.kpis.average_health ?? 0,
- worst_performer_path: overview.kpis.worst_performer_path ?? null,
- worst_performer_score: overview.kpis.worst_performer_score ?? null,
- open_findings: findingsPage?.total ?? overview.biomarkers?.length ?? 0,
- },
- distribution: distribution ?? null,
- defect_accuracy: overview.defect_accuracy ?? null,
- files: overview.files ?? [],
- top_findings: overview.biomarkers ?? [],
- modules: overview.modules ?? [],
- ...(overview.meta ? { meta: overview.meta } : {}),
- };
- },
- async listHealthFindings(repoId, opts): Promise<HealthFinding[]> {
- // Hosted paginates findings and filters by exact severity; the local
- // route returns a bare list with a minimum-severity filter. Fetch the
- // (server-filtered) page and apply the threshold client-side.
- const res = await snapGet<WireFindings>(repoId, "/health/findings", {
- biomarker: opts?.biomarker_type,
- file_path: opts?.file_path,
- dimension: opts?.dimension,
- limit: opts?.limit ?? 500,
- });
- let items = res.items ?? [];
- if (opts?.min_severity !== undefined && opts.min_severity in SEVERITY_ORDER) {
- const floor = SEVERITY_ORDER[opts.min_severity] as number;
- items = items.filter((f) => (SEVERITY_ORDER[f.severity] ?? 0) >= floor);
- }
- return items;
- },
- async listHealthFiles(repoId, opts): Promise<HealthFilesResponse> {
- // This route used to return a bare (server-sliced) list and now returns
- // the same windowed envelope the local route does. Accept both, since an
- // older deployment still answers with the array. Fetch a wide window and
- // apply the local windowing semantics client-side.
- const filter = opts?.only_hotspots
- ? "hotspots"
- : opts?.only_untested
- ? "untested"
- : opts?.only_failing
- ? "failing"
- : undefined;
- const res = await snapGet<HealthFilesResponse | HealthFilesResponse["files"]>(
- repoId,
- "/health/files",
- {
- limit: 2000,
- sort: opts?.sort,
- q: opts?.search,
- filter,
- },
- );
- const envelope = Array.isArray(res) ? null : res;
- let files: HealthFilesResponse["files"] = Array.isArray(res)
- ? res
- : (res?.files ?? []);
- // The server's total counts what it filtered; a client-side module
- // filter narrows further, so only trust the server total when we did not
- // narrow the set ourselves.
- let total = envelope?.total ?? files.length;
- if (opts?.module) {
- files = files.filter((f) => f.file_path.startsWith(opts.module as string));
- total = files.length;
- }
- if (opts?.order === "desc") files = [...files].reverse();
- const offset = opts?.offset ?? 0;
- const limit = opts?.limit ?? 50;
- return { total, offset, limit, files: files.slice(offset, offset + limit) };
- },
- getHealthFileBreakdown: (repoId, filePath) =>
- snapGet(repoId, "/health/files/breakdown", { file_path: filePath }),
- async getHealthTrend(repoId, limit = 20): Promise<HealthTrendResponse> {
- // Hosted serves the raw trend points; the local route pre-computes the
- // summary block. Derive it from the last two points; alerts and
- // per-file deltas are not exposed on hosted and stay empty.
- const res = await snapGet<WireTrend>(repoId, "/health/trend");
- const history = (res.points ?? []).slice(-limit).map((p) => ({
- taken_at: p.taken_at ?? null,
- hotspot_health: p.hotspot_health,
- average_health: p.average_health,
- worst_performer_path: p.worst_performer_path ?? null,
- worst_performer_score: p.worst_performer_score ?? null,
- }));
- const current = history.at(-1);
- const previous = history.at(-2);
- return {
- history,
- summary: {
- current_hotspot_health: current?.hotspot_health ?? 0,
- current_average_health: current?.average_health ?? 0,
- previous_hotspot_health: previous?.hotspot_health ?? null,
- previous_average_health: previous?.average_health ?? null,
- hotspot_delta:
- current && previous ? current.hotspot_health - previous.hotspot_health : null,
- average_delta:
- current && previous ? current.average_health - previous.average_health : null,
- },
- alerts: [],
- file_deltas: [],
- snapshot_count: history.length,
- };
- },
- getHealthCoverage: (repoId, opts) => snapGet(repoId, "/health/coverage", opts),
- getHealthWorkQueue: (repoId, opts) =>
- snapGet(repoId, "/health/refactoring-targets", opts as QueryParams),
- getRefactoringTargets: (repoId, opts) =>
- snapGet(repoId, "/health/refactoring-targets", opts as QueryParams),
- getRefactoringPlans: (repoId, opts = {}) =>
- snapGet(repoId, "/refactoring/targets", {
- refactoring_type: opts.refactoringType,
- min_confidence: opts.minConfidence,
- file_path: opts.filePath,
- view: opts.view,
- }),
- getRefactoringPlansPage: (repoId, opts = {}) =>
- snapGet(repoId, "/refactoring/targets/page", {
- refactoring_type: opts.refactoringType,
- min_confidence: opts.minConfidence,
- file_path: opts.filePath,
- view: opts.view,
- search: opts.search,
- confidence: opts.confidence,
- effort: opts.effort,
- sort: opts.sort,
- limit: opts.limit,
- offset: opts.offset,
- }),
- getRefactoringPlan: (repoId, planId) =>
- snapGet(repoId, `/refactoring/${encodeURIComponent(planId)}`),
- getPerformanceOpportunities: (repoId, opts = {}) => {
- // The file scope is the one list-valued member of the query, and the
- // parameter helper takes scalars, so it goes over the wire the way the
- // route reads it rather than as an array the serializer would drop.
- const { file_paths, ...rest } = opts;
- return snapGet(repoId, "/health/performance-opportunities", {
- ...rest,
- ...(file_paths?.length ? { file_paths: file_paths.join(",") } : {}),
- });
- },
- getPerformanceOpportunityFindings: (repoId, opportunityId, opts = {}) =>
- snapGet(
- repoId,
- `/health/performance-opportunities/${encodeURIComponent(opportunityId)}/findings`,
- opts,
- ),
- getChurnComplexity: (repoId, opts) => snapGet(repoId, "/health/churn-complexity", opts),
-
- listModuleHealth: (repoId, options = {}) => snapGet(repoId, "/modules/health", options),
- getModuleHealth: (repoId, modulePath) =>
- snapGet(repoId, `/modules/health/${encodeURIComponent(modulePath)}`),
-
- getC4L1: (repoId) => snapGet(repoId, "/c4/l1"),
- getC4L2: (repoId) => snapGet(repoId, "/c4/l2"),
- getC4L3: (repoId, containerId) => snapGet(repoId, "/c4/l3", { container_id: containerId }),
- getC4Mermaid: async (repoId, level, containerId) => {
- const params: QueryParams = { level };
- if (level === 3 && containerId) params.container_id = containerId;
- return getText(`/snapshots/${await snapshot(repoId)}/c4/mermaid`, params);
- },
- getArchitectureView: (repoId, includeSymbols = false) =>
- snapGet(repoId, "/architecture-view", { include_symbols: includeSymbols }),
- getArchitecture: (repoId) => snapGet(repoId, "/architecture"),
- getCommunitySlice: (repoId, communityId) =>
- snapGet(repoId, `/communities/${communityId}/slice`),
- getModuleGraph: (repoId) => snapGet(repoId, "/module-graph"),
- getExecutionFlows: (repoId, params) => snapGet(repoId, "/execution-flows", params),
- async getCoupling(repoId, opts): Promise<CouplingGraphResponse> {
- const res = await snapGet<WireCoupling>(repoId, "/coupling", opts);
- const nodes = res.nodes ?? [];
- // An older snapshot has no support/confidence/structural. Zero and null
- // read as "not measured", which the table already renders as a dash.
- const edges: CouplingEdge[] = (res.edges ?? []).map((e) => ({
- source: e.source ?? "",
- target: e.target ?? "",
- strength: e.strength ?? 0,
- last_co_change: e.last_co_change ?? null,
- support: e.support ?? 0,
- confidence_ab: e.confidence_ab ?? null,
- confidence_ba: e.confidence_ba ?? null,
- structural: e.structural ?? null,
- dependency_kind: e.dependency_kind ?? null,
- }));
- // Falling back to the post-cap length understates the pre-cap count, but
- // an honest "showing N of N" beats `NaN` downstream.
- return {
- nodes,
- edges,
- total_edges: res.total_edges ?? edges.length,
- // An older snapshot carries no file count; deriving one from the
- // capped edges would understate it, and 0 already reads as unknown.
- coupled_files: res.coupled_files ?? 0,
- total_files: res.total_files ?? 0,
- };
- },
-
- async getFilesIndex(repoId): Promise<FilesIndexResponse> {
- // Same rows, different envelope: hosted totals/language_counts vs the
- // local total/languages.
- const res = await snapGet<WireFilesIndex>(repoId, "/files");
- return {
- files: res.files ?? [],
- total: res.totals?.files ?? (res.files ?? []).length,
- languages: Object.entries(res.language_counts ?? {}).map(([language, count]) => ({
- language,
- count,
- })),
- };
- },
- getFileDetail: (repoId, filePath) => snapGet(repoId, "/files/detail", { path: filePath }),
- getSymbolDetail: (repoId, symbolId) =>
- snapGet(repoId, "/symbols/detail", { symbol_id: symbolId }),
-
- async getDocsStatus(repoId): Promise<HostedDocsStatus> {
- const docs = await getDocs(repoId);
- return {
- available: docs.available,
- docs_status: docs.docs_status ?? null,
- pages_ready: docs.pages_ready ?? 0,
- pages_total: docs.pages_total ?? null,
- };
- },
- async listPages(repoId, opts): Promise<PageResponse[]> {
- let pages = await loadPages(repoId);
- if (opts?.page_type) pages = pages.filter((p) => p.page_type === opts.page_type);
- const offset = opts?.offset ?? 0;
- if (offset || opts?.limit !== undefined) {
- pages = pages.slice(offset, opts?.limit !== undefined ? offset + opts.limit : undefined);
- }
- return pages;
- },
- listAllPages,
- async getPageById(pageId, repoId): Promise<PageResponse> {
- const pools = repoId
- ? [await loadPages(repoId)]
- : Array.from(pagesBySnapshot.values());
- for (const pool of pools) {
- const hit = pool.find((p) => p.id === pageId);
- if (hit) return hit;
- }
- throw new ApiClientError(404, `Page not found: ${pageId}`);
- },
-
- async listDecisions(repoId, opts): Promise<DecisionRecordResponse[]> {
- const res = await snapGet<WireDecisions>(repoId, "/decisions", opts);
- return (res.decisions ?? []) as unknown as DecisionRecordResponse[];
- },
- async listDeadCode(repoId, opts): Promise<DeadCodeFindingResponse[]> {
- // Hosted paginates but does not filter; filters apply client-side over
- // the full report so semantics match the local server.
- const res = await snapGet<WireDeadCode>(repoId, "/dead-code", { limit: 500 });
- let findings = (res.findings ?? []).map(mapHostedDeadCodeFinding);
- if (opts?.kind) findings = findings.filter((f) => f.kind === opts.kind);
- if (opts?.min_confidence !== undefined) {
- findings = findings.filter((f) => f.confidence >= (opts.min_confidence as number));
- }
- if (opts?.status) findings = findings.filter((f) => f.status === opts.status);
- if (opts?.safe_only) findings = findings.filter((f) => f.safe_to_delete);
- return opts?.limit !== undefined ? findings.slice(0, opts.limit) : findings;
- },
- getHotspotsPage: (repoId, options = {}) => {
- const { limit = 50, offset = 0 } = options;
- return snapGet(repoId, "/hotspots", { limit, offset });
- },
- async getHotspots(repoId, limit = 50): Promise<HotspotResponse[]> {
- const page = await snapGet<Paginated<HotspotResponse>>(repoId, "/hotspots", { limit });
- return page.items;
- },
- getCoChanges: (repoId, filePath, minCount = 3) =>
- snapGet(repoId, "/co-changes", { file_path: filePath, min_count: minCount }),
- getGitSummary: (repoId, topOwnersLimit) =>
- snapGet(
- repoId,
- "/git-summary",
- topOwnersLimit ? { top_owners_limit: topOwnersLimit } : undefined,
- ),
-
- async search(query, opts): Promise<SearchResultResponse[]> {
- if (!opts?.repo_id) {
- throw new ApiClientError(400, "Hosted search requires a repo_id");
- }
- const sid = await snapshot(opts.repo_id);
- const res = await post<WireSearch>(`/snapshots/${sid}/search`, {
- query,
- limit: opts.limit ?? 10,
- });
- return (res.results ?? []).map(mapHostedSearchResult);
- },
-
- triggerReindex: (repoId, opts) =>
- post(`/repos/${repoId}/reindex`, {
- generate_docs: opts?.generate_docs ?? false,
- ...(opts?.docs_file_percentage !== undefined
- ? { docs_file_percentage: opts.docs_file_percentage }
- : {}),
- }),
- getSnapshotStatus: (snapshotId) => get(`/snapshots/${snapshotId}`),
- };
-}
diff --git a/packages/api-client/src/package-exports.test.ts b/packages/api-client/src/package-exports.test.ts
index 08f588b4b..4ecc3bbbc 100644
--- a/packages/api-client/src/package-exports.test.ts
+++ b/packages/api-client/src/package-exports.test.ts
@@ -1,6 +1,5 @@
-// The export map is the published contract. `./hosted` in particular is
-// consumed only from outside this repo, so nothing else in here would fail if
-// a packaging change dropped it.
+// The export map is the published contract, and subpaths consumed only from
+// outside this repo would fail nowhere in here if a packaging change broke them.
import { existsSync } from "node:fs";
import { dirname, join, resolve } from "node:path";
import { fileURLToPath } from "node:url";
@@ -13,10 +12,6 @@ const packageRoot = resolve(dirname(fileURLToPath(import.meta.url)), "..");
const exportMap = manifest.exports as Record<string, string>;
describe("published export map", () => {
- it("keeps the hosted provider reachable", () => {
- expect(exportMap["./hosted"]).toBe("./src/hosted.ts");
- });
-
it("points every subpath at a file that exists", () => {
const missing = Object.entries(exportMap).filter(
([, target]) => !existsSync(join(packageRoot, target)),
diff --git a/packages/core/src/repowise/core/analysis/change_health/service.py b/packages/core/src/repowise/core/analysis/change_health/service.py
index d6e5860a1..e9443c531 100644
--- a/packages/core/src/repowise/core/analysis/change_health/service.py
+++ b/packages/core/src/repowise/core/analysis/change_health/service.py
@@ -58,14 +58,21 @@ _INCIDENTAL_BASES = {"file_change", "context_change", "unknown"}
@dataclass(frozen=True, slots=True)
class DeltaRequest:
- repo_path: str
+ """What to compare. ``repo_path`` is unused by the comparison; ``None`` is fine."""
+
+ repo_path: str | None
revspec: str | None
extensions: tuple[str, ...] = ()
exclude_patterns: tuple[str, ...] = ()
class ChangeHealthDeltaService:
- """Compare the health of two revisions of the same repository."""
+ """Compare the health of two revisions of the same repository.
+
+ Without a checkout, pass a ``MappingRevisionSource`` (diff hunks plus raw
+ bytes at both SHAs). Both sides are re-scored from those bytes, so custom
+ health rules need ``RevisionHealthAnalyzer(config=...)`` to match the index.
+ """
def __init__(
self,
diff --git a/packages/core/src/repowise/core/analysis/health/aggregation.py b/packages/core/src/repowise/core/analysis/health/aggregation.py
index e959f6645..134d1e17c 100644
--- a/packages/core/src/repowise/core/analysis/health/aggregation.py
+++ b/packages/core/src/repowise/core/analysis/health/aggregation.py
@@ -13,7 +13,7 @@ from __future__ import annotations
from collections.abc import Iterable, Mapping, Sequence
from typing import Any
-from .models import Severity
+from .models import Severity, primary_finding
from .ranking import worst_metric
from .rows import detail_map, field
from .scoring import (
@@ -34,6 +34,8 @@ __all__ = [
"finding_raw_deduction",
"module_label",
"module_rollups",
+ "primary_and_magnitude",
+ "primary_and_magnitude_by_file",
"score_breakdown",
"severity_breakdown",
]
@@ -205,6 +207,31 @@ def finding_raw_deduction(finding: Any) -> float:
)
+def primary_and_magnitude(findings: Sequence[Any]) -> dict[str, Any]:
+ """Dominant cause + pre-clamp deduction magnitude for one file's findings.
+
+ ``total_deduction`` sums stored ``health_impact``, the applied (capped)
+ value; :func:`finding_raw_deduction` is unscaled and differs on capped files.
+ """
+ if not findings:
+ return {"primary_biomarker": None, "primary_reason": None, "total_deduction": None}
+ primary = primary_finding(findings)
+ total = sum(float(field(x, "health_impact", 0.0) or 0.0) for x in findings)
+ return {
+ "primary_biomarker": field(primary, "biomarker_type") if primary else None,
+ "primary_reason": field(primary, "reason") if primary else None,
+ "total_deduction": round(total, 3),
+ }
+
+
+def primary_and_magnitude_by_file(findings: Iterable[Any]) -> dict[str, dict[str, Any]]:
+ """:func:`primary_and_magnitude` for each ``file_path`` in *findings*."""
+ by_file: dict[str, list[Any]] = {}
+ for f in findings:
+ by_file.setdefault(field(f, "file_path"), []).append(f)
+ return {path: primary_and_magnitude(fs) for path, fs in by_file.items()}
+
+
def score_breakdown(findings: Sequence[Any]) -> dict[str, Any]:
"""Reconstruct one file's per-category deductions from its open findings.
diff --git a/packages/core/src/repowise/core/analysis/health/models.py b/packages/core/src/repowise/core/analysis/health/models.py
index e70b6bdc1..97c769daf 100644
--- a/packages/core/src/repowise/core/analysis/health/models.py
+++ b/packages/core/src/repowise/core/analysis/health/models.py
@@ -59,6 +59,7 @@ def primary_finding(findings: Sequence[Any]) -> Any | None:
``coverage_gradient``.
"""
from .biomarkers.registry import continuous_biomarkers
+ from .rows import field as row_field
from .scoring import is_advisory
if not findings:
@@ -66,12 +67,19 @@ def primary_finding(findings: Sequence[Any]) -> Any | None:
# An advisory finding describes; it never accuses. Leaving it eligible made
# it the stated "one reason" for any file whose only open finding was
# advisory - printed beside a total deduction of zero.
- candidates = [item for item in findings if not is_advisory(item.biomarker_type)]
+ candidates = [
+ item for item in findings if not is_advisory(row_field(item, "biomarker_type"))
+ ]
if not candidates:
return None
continuous = continuous_biomarkers()
- discrete = [item for item in candidates if item.biomarker_type not in continuous]
- return max(discrete or candidates, key=lambda item: float(item.health_impact or 0.0))
+ discrete = [
+ item for item in candidates if row_field(item, "biomarker_type") not in continuous
+ ]
+ return max(
+ discrete or candidates,
+ key=lambda item: float(row_field(item, "health_impact") or 0.0),
+ )
def split_by_origin(findings: Iterable[Any]) -> tuple[list[Any], list[Any]]:
diff --git a/packages/core/src/repowise/core/ingestion/models.py b/packages/core/src/repowise/core/ingestion/models.py
index cc8aee259..069ff51f3 100644
--- a/packages/core/src/repowise/core/ingestion/models.py
+++ b/packages/core/src/repowise/core/ingestion/models.py
@@ -301,8 +301,12 @@ class CallSite:
supplied_props: set[str] | None = None # prop names supplied in JSX element (None if unknown/spread)
+# Raw extractor kinds, not the TS ``HeritageKind`` (a different payload);
+# test_wire_vocabulary_parity pins the difference.
HeritageKind = Literal["extends", "implements", "trait_impl", "mixin", "derive"]
+HERITAGE_KIND_VALUES: frozenset[str] = frozenset(get_args(HeritageKind))
+
@dataclass
class HeritageRelation:
diff --git a/packages/server/src/repowise/server/routers/code_health/serializers.py b/packages/server/src/repowise/server/routers/code_health/serializers.py
index d5bc973dc..c003ea39e 100644
--- a/packages/server/src/repowise/server/routers/code_health/serializers.py
+++ b/packages/server/src/repowise/server/routers/code_health/serializers.py
@@ -5,7 +5,10 @@ from __future__ import annotations
import json
from typing import Any
-from repowise.core.analysis.health.models import primary_finding
+from repowise.core.analysis.health.aggregation import (
+ primary_and_magnitude,
+ primary_and_magnitude_by_file,
+)
from repowise.core.analysis.health.scoring import unclamped_score
from repowise.core.analysis.health.signals import FileSignals
from repowise.core.analysis.health.trends import FileTrend
@@ -40,40 +43,9 @@ def _round_opt(v: Any) -> float | None:
return round(v, 2) if v is not None else None
-def _primary_and_magnitude(findings: list[Any]) -> dict:
- """Dominant cause + pre-clamp deduction magnitude for one file's findings.
-
- Two presentation signals the score alone can't carry:
-
- - ``primary_biomarker`` / ``primary_reason`` — the single worst finding, so a
- low file can lead with "the one reason" instead of a wall of markers.
- - ``total_deduction`` — the summed (pre-floor) ``health_impact``. Equal to
- the breakdown endpoint's ``total_deduction`` (each finding's stored impact
- is already the applied, capped value), so it distinguishes two files that
- both floor at 1.0 (a -25 file from a -9 one) without touching ``score``.
-
- All-null on an empty list: a clean file has no lead and no magnitude. A
- file whose every finding is advisory gets a null lead and a real magnitude
- of zero -- ``primary_finding`` declines to name a cause that deducts
- nothing, and reading that refusal as a finding raised here instead.
- """
- if not findings:
- return {"primary_biomarker": None, "primary_reason": None, "total_deduction": None}
- primary = primary_finding(findings)
- total = sum(float(x.health_impact or 0.0) for x in findings)
- return {
- "primary_biomarker": primary.biomarker_type if primary else None,
- "primary_reason": primary.reason if primary else None,
- "total_deduction": round(total, 3),
- }
-
-
-def _leads_by_file(findings: list[Any]) -> dict[str, dict]:
- """Group findings by file and reduce each group to its dominant-cause lead."""
- by_file: dict[str, list[Any]] = {}
- for f in findings:
- by_file.setdefault(f.file_path, []).append(f)
- return {path: _primary_and_magnitude(fs) for path, fs in by_file.items()}
+# Old names kept for the routes and tests that import them.
+_primary_and_magnitude = primary_and_magnitude
+_leads_by_file = primary_and_magnitude_by_file
def _metric_to_dict(
diff --git a/tests/unit/change_health/test_supplied_source_parity.py b/tests/unit/change_health/test_supplied_source_parity.py
index f3d0b985d..e00312474 100644
--- a/tests/unit/change_health/test_supplied_source_parity.py
+++ b/tests/unit/change_health/test_supplied_source_parity.py
@@ -93,6 +93,27 @@ def test_health_delta_is_identical_across_sources(make_repo, revspec):
]
+def test_supplied_source_needs_no_repo_path(make_repo):
+ """A caller with no checkout has content and SHAs, never a path."""
+ repo: Repo = make_repo("parity")
+ repo.commit("base", {"app/a.py": python_complex("run", 2)})
+ repo.commit("head", {"app/a.py": python_complex("run", 9)})
+
+ from_git = ChangeHealthDeltaService(repo_path=str(repo.path)).compare(
+ DeltaRequest(repo_path=str(repo.path), revspec="HEAD")
+ )
+
+ supplied = _mirror(GitRevisionSource(str(repo.path)), "HEAD")
+ from_supplied = ChangeHealthDeltaService(supplied).compare(
+ DeltaRequest(repo_path=None, revspec="HEAD")
+ )
+
+ assert from_git.findings, "the fixture must surface findings to compare"
+ assert from_supplied.status == from_git.status
+ assert from_supplied.scope == from_git.scope
+ assert from_supplied.findings == from_git.findings
+
+
# ---------------------------------------------------------------------------
# Change shapes that must survive the round trip
# ---------------------------------------------------------------------------
diff --git a/tests/unit/health/test_primary_and_magnitude.py b/tests/unit/health/test_primary_and_magnitude.py
new file mode 100644
index 000000000..3c8db8538
--- /dev/null
+++ b/tests/unit/health/test_primary_and_magnitude.py
@@ -0,0 +1,78 @@
+"""Golden pins for the per-file lead fold the code-health routes serve."""
+
+from __future__ import annotations
+
+from types import SimpleNamespace
+
+from repowise.server.routers.code_health import _leads_by_file, _primary_and_magnitude
+
+
+def _f(path, biomarker, impact, reason=""):
+ return SimpleNamespace(
+ file_path=path, biomarker_type=biomarker, health_impact=impact, reason=reason
+ )
+
+
+FINDINGS = [
+ # Continuous marker has the larger impact but a discrete one leads.
+ _f("a.py", "coverage_gradient", 2.4567, "71% uncovered"),
+ _f("a.py", "complex_method", 1.1111, "ccn 18"),
+ _f("a.py", "deep_nesting", 0.3334, "nests 5"),
+ # Continuous marker alone still leads.
+ _f("b.py", "coverage_gradient", 0.9, "40% uncovered"),
+ # Advisory only: no lead, real zero magnitude.
+ _f("c.py", "assertion_free_test", 0.0, "no asserts"),
+ # Null impact counts as zero; ties keep the first.
+ _f("d.py", "god_object", None, "big"),
+ _f("d.py", "long_method", 0.1, "90 lines"),
+ _f("d.py", "complex_method", 0.1, "ccn 11"),
+]
+
+GOLDEN = {
+ "a.py": {
+ "primary_biomarker": "complex_method",
+ "primary_reason": "ccn 18",
+ "total_deduction": 3.901,
+ },
+ "b.py": {
+ "primary_biomarker": "coverage_gradient",
+ "primary_reason": "40% uncovered",
+ "total_deduction": 0.9,
+ },
+ "c.py": {"primary_biomarker": None, "primary_reason": None, "total_deduction": 0.0},
+ "d.py": {
+ "primary_biomarker": "long_method",
+ "primary_reason": "90 lines",
+ "total_deduction": 0.2,
+ },
+}
+
+
+def test_leads_by_file_golden() -> None:
+ assert _leads_by_file(FINDINGS) == GOLDEN
+
+
+def test_primary_and_magnitude_golden_per_file() -> None:
+ for path, expected in GOLDEN.items():
+ assert _primary_and_magnitude([f for f in FINDINGS if f.file_path == path]) == expected
+
+
+def test_primary_and_magnitude_empty() -> None:
+ assert _primary_and_magnitude([]) == {
+ "primary_biomarker": None,
+ "primary_reason": None,
+ "total_deduction": None,
+ }
+
+
+def test_route_names_are_the_core_fold() -> None:
+ from repowise.core.analysis.health import aggregation
+
+ assert _primary_and_magnitude is aggregation.primary_and_magnitude
+ assert _leads_by_file is aggregation.primary_and_magnitude_by_file
+
+
+def test_plain_dicts_fold_like_rows() -> None:
+ from repowise.core.analysis.health.aggregation import primary_and_magnitude_by_file
+
+ assert primary_and_magnitude_by_file([vars(f) for f in FINDINGS]) == GOLDEN
diff --git a/tests/unit/server/test_wire_vocabulary_parity.py b/tests/unit/server/test_wire_vocabulary_parity.py
index bf51c38b7..5dbc11b4a 100644
--- a/tests/unit/server/test_wire_vocabulary_parity.py
+++ b/tests/unit/server/test_wire_vocabulary_parity.py
@@ -15,7 +15,7 @@ import pathlib
import re
from repowise.core.analysis.execution_flows import FLOW_TERMINATION_VALUES
-from repowise.core.ingestion.models import RESOLUTION_ORIGIN_VALUES
+from repowise.core.ingestion.models import HERITAGE_KIND_VALUES, RESOLUTION_ORIGIN_VALUES
from repowise.core.workspace.diagnostics import UNMATCHED_REASON_VALUES
_TYPES_SRC = pathlib.Path(__file__).resolve().parents[3] / "packages/types/src"
@@ -39,3 +39,11 @@ def test_flow_termination_union_matches_python() -> None:
def test_unmatched_reason_union_matches_python() -> None:
assert _union_members("UnmatchedReason", "workspace.ts") == set(UNMATCHED_REASON_VALUES)
+
+
+def test_heritage_kind_differs_from_python_only_where_documented() -> None:
+ """Not a mirror: TS types a different payload, so a new member on either
+ side must be placed on purpose."""
+ ts = _union_members("HeritageKind", "symbols.ts")
+ assert ts - set(HERITAGE_KIND_VALUES) == {"method_implements", "method_overrides"}
+ assert set(HERITAGE_KIND_VALUES) - ts == {"derive"}