diff --git a/pyproject.toml b/pyproject.toml
index 967a047..948444a 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -40,6 +40,9 @@ Issues = "https://github.com/EhsanAzish80/Devscope/issues"
Changelog = "https://github.com/EhsanAzish80/Devscope/releases"
[project.optional-dependencies]
+graph = [
+ "tree-sitter-language-pack>=0.9.0; python_version >= '3.10'",
+]
dev = [
"pytest>=7.4.0",
"pytest-cov>=4.1.0",
@@ -98,7 +101,7 @@ check_untyped_defs = true
strict_equality = true
[[tool.mypy.overrides]]
-module = ["gitpython", "git.*"]
+module = ["gitpython", "git.*", "tree_sitter_language_pack"]
ignore_missing_imports = true
[tool.pytest.ini_options]
diff --git a/src/devscope/analyzers/hotspots.py b/src/devscope/analyzers/hotspots.py
index a6e347d..49df696 100644
--- a/src/devscope/analyzers/hotspots.py
+++ b/src/devscope/analyzers/hotspots.py
@@ -6,12 +6,10 @@
class HotspotDetector:
- """Detects code hotspots using LOC, depth, and test proximity."""
+ """Legacy size-only hotspot detector used outside PR risk ranking."""
# Risk scoring weights
- WEIGHT_LOC = 0.4
- WEIGHT_DEPTH = 0.3
- WEIGHT_NO_TESTS = 0.3
+ WEIGHT_LOC = 1.0
# Thresholds
HIGH_LOC_THRESHOLD = 500
@@ -143,6 +141,7 @@ def _calculate_risk_score(self, loc: int, depth: int, has_nearby_tests: bool) ->
Returns:
Risk score (0-100)
"""
+ del depth, has_nearby_tests
# LOC component (0-100)
if loc > self.HIGH_LOC_THRESHOLD:
loc_score = 100.0
@@ -153,18 +152,7 @@ def _calculate_risk_score(self, loc: int, depth: int, has_nearby_tests: bool) ->
else:
loc_score = loc * 50 / self.MEDIUM_LOC_THRESHOLD
- # Depth component (0-100)
- depth_score = float(min(100, (depth / self.HIGH_DEPTH_THRESHOLD) * 100))
-
- # Test proximity component (0 or 100)
- test_score = 0 if has_nearby_tests else 100
-
- # Weighted combination
- risk_score = (
- self.WEIGHT_LOC * loc_score
- + self.WEIGHT_DEPTH * depth_score
- + self.WEIGHT_NO_TESTS * test_score
- )
+ risk_score = self.WEIGHT_LOC * loc_score
return round(risk_score, 1)
diff --git a/src/devscope/demo.py b/src/devscope/demo.py
index 0080c9c..615902d 100644
--- a/src/devscope/demo.py
+++ b/src/devscope/demo.py
@@ -29,7 +29,7 @@ def demo_report() -> dict[str, Any]:
"evidence": {"uncovered_lines": list(range(453, 465))},
}
return {
- "schema_version": "1.0",
+ "schema_version": 2,
"kind": "review",
"demo": True,
"target_commit": "1" * 40,
@@ -38,12 +38,32 @@ def demo_report() -> dict[str, Any]:
"history": {"commits_analyzed": 40, "limit": 200, "revision": "1" * 40},
"packages": [],
"package_summary": [],
+ "model": {"fitted": False},
"changed_source_files": 2,
"checklist": [
{
"path": "billing/service.py",
"line": 453,
"lines": 635,
+ "risk": 0.81,
+ "rank": 1,
+ "calibration": "global",
+ "evidence": [
+ {
+ "kind": "defect_history",
+ "weight": 0.34,
+ "text": "7 bug fixes traced to this file in 12 months",
+ "refs": ["a1b2c3d"],
+ },
+ {
+ "kind": "missing_cochange",
+ "weight": 0.21,
+ "text": "billing/models.py changed with this file in 6 commits; not in this diff",
+ "refs": ["billing/models.py"],
+ },
+ ],
+ "mitigating": [],
+ "context": {"ai_authored_lines": 112, "owners": ["@alice"]},
"recent_commits": 12,
"related_files": [{"path": "billing/models.py", "cochanges": 6}],
"findings": [size, missed],
@@ -58,6 +78,12 @@ def demo_report() -> dict[str, Any]:
"path": "auth/session.py",
"line": 24,
"lines": 148,
+ "risk": 0.12,
+ "rank": 2,
+ "calibration": "global",
+ "evidence": [],
+ "mitigating": [],
+ "context": {},
"recent_commits": 3,
"related_files": [],
"findings": [],
@@ -143,9 +169,7 @@ def render_demo(console: "Console", report: dict[str, Any]) -> None:
" Check interactions",
f"{related['path']}{separator}{related['cochanges']} observed co-changes",
)
- table.add_row(
- second["path"], f"{second['lines']} lines{separator}no configured warning triggered"
- )
+ table.add_row(second["path"], f"Risk {second['risk']:.2f}")
console.print(table)
console.print(
f"\n[bold]Sample patch coverage:[/bold] {report['coverage']['percent']}% of mapped added executable lines"
diff --git a/src/devscope/graph/__init__.py b/src/devscope/graph/__init__.py
new file mode 100644
index 0000000..b018dac
--- /dev/null
+++ b/src/devscope/graph/__init__.py
@@ -0,0 +1,5 @@
+"""Optional point-in-time source import graph."""
+
+from devscope.graph.imports import graph_available, import_edges
+
+__all__ = ["graph_available", "import_edges"]
diff --git a/src/devscope/graph/imports.py b/src/devscope/graph/imports.py
new file mode 100644
index 0000000..bc93954
--- /dev/null
+++ b/src/devscope/graph/imports.py
@@ -0,0 +1,108 @@
+"""Tree-sitter-backed import extraction for supported source languages."""
+
+from __future__ import annotations
+
+import re
+from pathlib import PurePosixPath
+from typing import Any
+
+LANGUAGES = {
+ ".py": "python",
+ ".js": "javascript",
+ ".jsx": "javascript",
+ ".ts": "typescript",
+ ".tsx": "tsx",
+ ".go": "go",
+ ".swift": "swift",
+ ".rs": "rust",
+}
+IMPORT_NODES = {
+ "python": {"import_statement", "import_from_statement"},
+ "javascript": {"import_statement", "export_statement", "call_expression"},
+ "typescript": {"import_statement", "export_statement", "call_expression"},
+ "tsx": {"import_statement", "export_statement", "call_expression"},
+ "go": {"import_spec"},
+ "swift": {"import_declaration"},
+ "rust": {"use_declaration", "extern_crate_declaration"},
+}
+
+
+def _provider() -> Any | None:
+ try:
+ from tree_sitter_language_pack import get_parser
+ except ImportError:
+ return None
+ return get_parser
+
+
+def graph_available() -> bool:
+ """Return whether the optional graph parser extra is installed."""
+ return _provider() is not None
+
+
+def _walk(node: Any) -> list[Any]:
+ result = [node]
+ for child in node.children:
+ result.extend(_walk(child))
+ return result
+
+
+def _module_candidates(path: str, module: str) -> list[str]:
+ current = PurePosixPath(path).parent
+ cleaned = module.strip("'\"; ")
+ if cleaned.startswith("."):
+ relative = current.joinpath(cleaned).as_posix()
+ else:
+ relative = cleaned.replace("::", "/").replace(".", "/")
+ relative = re.sub(r"/+", "/", relative).lstrip("./")
+ parts = [part for part in relative.split("/") if part]
+ candidates = [relative, f"{relative}/index", f"{relative}/__init__"]
+ if parts:
+ candidates.append(parts[-1])
+ if parts and parts[0] in {"crate", "self", "super"}:
+ candidates.extend("/".join(parts[1:end]) for end in range(len(parts), 1, -1))
+ return candidates
+
+
+def _resolve(path: str, module: str, known_paths: set[str]) -> str | None:
+ extensions = tuple(LANGUAGES)
+ for candidate in _module_candidates(path, module):
+ for known in known_paths:
+ stem = known
+ for extension in extensions:
+ if stem.endswith(extension):
+ stem = stem[: -len(extension)]
+ break
+ if stem == candidate or stem.endswith("/" + candidate):
+ return known
+ return None
+
+
+def import_edges(path: str, source: str, known_paths: set[str]) -> set[str]:
+ """Return repository paths imported by ``path`` using its syntax tree."""
+ language = LANGUAGES.get(PurePosixPath(path).suffix.lower())
+ get_parser = _provider()
+ if language is None or get_parser is None or not source:
+ return set()
+ tree = get_parser(language).parse(source.encode("utf-8"))
+ modules: set[str] = set()
+ data = source.encode("utf-8")
+ for node in _walk(tree.root_node):
+ if node.type not in IMPORT_NODES[language]:
+ continue
+ text = data[node.start_byte : node.end_byte].decode("utf-8", errors="replace")
+ quoted = re.findall(r"['\"]([^'\"]+)['\"]", text)
+ modules.update(quoted)
+ if language == "python":
+ match = re.search(r"(?:from|import)\s+([.\w]+)", text)
+ if match:
+ modules.add(match.group(1))
+ elif language == "swift":
+ match = re.search(r"\bimport\s+(?:\w+\s+)?([\w.]+)", text)
+ if match:
+ modules.add(match.group(1))
+ elif language == "rust":
+ match = re.search(r"\b(?:use|crate)\s+([\w:]+)", text)
+ if match:
+ modules.add(match.group(1))
+ return {target for module in modules if (target := _resolve(path, module, known_paths))}
diff --git a/src/devscope/index/git_reader.py b/src/devscope/index/git_reader.py
index 04854db..c087279 100644
--- a/src/devscope/index/git_reader.py
+++ b/src/devscope/index/git_reader.py
@@ -3,6 +3,7 @@
import os
import subprocess
from collections.abc import Sequence
+from concurrent.futures import ThreadPoolExecutor
from dataclasses import dataclass
from pathlib import Path
from typing import Optional
@@ -75,12 +76,18 @@ def run(cwd: Path, *args: str, input_text: Optional[str] = None) -> str:
)
if completed.returncode != 0:
detail = completed.stderr.strip() or "Git command failed"
+ lowered = detail.lower()
+ if "promisor remote" in lowered or "lazy fetch" in lowered:
+ raise GitError(
+ "Repository is missing promised Git objects. Use a full clone or run "
+ "`git fetch --refetch` before indexing."
+ )
raise GitError(detail)
return completed.stdout
- def head(self) -> str:
- """Return the current commit."""
- return self.run(self.root, "rev-parse", "--verify", "HEAD").strip()
+ def head(self, ref: str = "HEAD") -> str:
+ """Resolve a commit ref without assuming the working tree branch."""
+ return self.run(self.root, "rev-parse", "--verify", f"{ref}^{{commit}}").strip()
def is_ancestor(self, older: str, newer: str) -> bool:
"""Return whether older is reachable from newer."""
@@ -90,12 +97,12 @@ def is_ancestor(self, older: str, newer: str) -> bool:
return False
return True
- def revisions(self, *, since: Optional[str], max_count: int) -> list[str]:
+ def revisions(self, *, since: Optional[str], max_count: int, ref: str = "HEAD") -> list[str]:
"""Return the selected history oldest first."""
args = ["rev-list", "--topo-order", f"--max-count={max_count}"]
if since:
args.append(f"--since={since}")
- args.append("HEAD")
+ args.append(ref)
return list(reversed(self.run(self.root, *args).splitlines()))
def commit_info(self, sha: str) -> CommitInfo:
@@ -105,7 +112,7 @@ def commit_info(self, sha: str) -> CommitInfo:
"show",
"-s",
"--no-show-signature",
- "--format=%H%x1f%P%x1f%an%x1f%ae%x1f%at%x1f%ct%x1f%B%x1e",
+ "--format=%H%x1f%P%x1f%aN%x1f%aE%x1f%at%x1f%ct%x1f%B%x1e",
sha,
)
fields = payload.rstrip("\n\x1e").split("\x1f", 6)
@@ -132,7 +139,7 @@ def commit_infos(self, revisions: Sequence[str]) -> dict[str, CommitInfo]:
"--stdin",
"-z",
"--no-show-signature",
- "--format=%H%x00%P%x00%an%x00%ae%x00%at%x00%ct%x00%B",
+ "--format=%H%x00%P%x00%aN%x00%aE%x00%at%x00%ct%x00%B",
input_text="\n".join(revisions),
)
fields = payload.rstrip("\0").split("\0")
@@ -154,6 +161,67 @@ def commit_infos(self, revisions: Sequence[str]) -> dict[str, CommitInfo]:
)
return result
+ def landed_at_pending(
+ self, pending: Sequence[str], infos: dict[str, CommitInfo], ref: str = "HEAD"
+ ) -> dict[str, int]:
+ """Map only newly indexed commits to their first-parent landing timestamps."""
+ selected = set(pending)
+ if not selected:
+ return {}
+ first_parent_rows = self.run(
+ self.root, "rev-list", "--first-parent", "--parents", ref
+ ).splitlines()
+ first_parent = [row.split()[0] for row in first_parent_rows]
+ parents_by_sha: dict[str, tuple[str, ...]] = {}
+ for row in first_parent_rows:
+ parts = row.split()
+ parents_by_sha[parts[0]] = tuple(parts[1:])
+ mainline = set(first_parent)
+ result = {
+ sha: infos[sha].committed_at for sha in selected.intersection(mainline) if sha in infos
+ }
+ merges = [
+ (sha, infos[sha].parents[0], infos[sha].committed_at)
+ for sha in reversed(first_parent)
+ if sha in infos and len(infos[sha].parents) > 1
+ ]
+
+ def merged_commits(item: tuple[str, str, int]) -> list[str]:
+ merge_sha, first_parent_sha, _landed_at = item
+ return self.run(self.root, "rev-list", f"^{first_parent_sha}", merge_sha).splitlines()
+
+ if merges:
+ workers = min(8, len(merges))
+ with ThreadPoolExecutor(max_workers=workers) as executor:
+ batches = list(executor.map(merged_commits, merges))
+ for (_merge_sha, _first_parent_sha, landed_at), commits in zip(merges, batches):
+ for sha in commits:
+ if sha in selected and sha not in mainline and sha not in result:
+ result[sha] = landed_at
+
+ missing = selected.difference(result)
+ if missing:
+ new_merge_shas = {item[0] for item in merges}
+ for merge_sha in reversed(first_parent):
+ parents = parents_by_sha[merge_sha]
+ if len(parents) <= 1 or merge_sha in new_merge_shas:
+ continue
+ reachable = set(
+ self.run(self.root, "rev-list", f"^{parents[0]}", merge_sha).splitlines()
+ )
+ matched = missing.intersection(reachable)
+ if not matched:
+ continue
+ landed_at = self.commit_info(merge_sha).committed_at
+ for sha in matched:
+ result[sha] = landed_at
+ missing.difference_update(matched)
+ if not missing:
+ break
+ if missing:
+ raise GitError(f"Could not determine landing time for {len(missing)} commits")
+ return result
+
def changes(self, sha: str) -> list[FileChange]:
"""Read rename-aware numstat entries for one commit."""
raw = self.run(
diff --git a/src/devscope/index/incremental.py b/src/devscope/index/incremental.py
index 316c595..87a5ca7 100644
--- a/src/devscope/index/incremental.py
+++ b/src/devscope/index/incremental.py
@@ -8,6 +8,7 @@
from pathlib import Path
from typing import Optional
+from devscope.graph.imports import graph_available, import_edges
from devscope.index.git_reader import CommitInfo, FileChange, GitReader
from devscope.index.store import IndexStore, cache_path
from devscope.szz.blame import added_lines, parse_blame, removed_ranges
@@ -16,7 +17,7 @@
DEFAULT_SINCE = "3 years ago"
DEFAULT_MAX_COMMITS = 5_000
-ENGINE_VERSION = 2
+ENGINE_VERSION = 5
MAX_FIX_FILES = 50
MAX_FIX_LINES = 5_000
@@ -96,26 +97,34 @@ def __init__(
since: Optional[str] = None,
max_commits: int = DEFAULT_MAX_COMMITS,
max_workers: Optional[int] = None,
+ ref: str = "HEAD",
) -> None:
self.git = GitReader(path)
self.since = since or DEFAULT_SINCE
self.max_commits = max_commits
self.max_workers = max_workers or min(8, os.cpu_count() or 1)
+ self.ref = ref
self.path = cache_path(self.git.common_dir)
self._commit_infos: dict[str, CommitInfo] = {}
self._changes: dict[str, list[FileChange]] = {}
+ self._landed_at: dict[str, int] = {}
self._szz_jobs: list[_SzzJob] = []
def build(self, *, rebuild: bool = False) -> IndexResult:
- head = self.git.head()
- revisions = self.git.revisions(since=self.since, max_count=self.max_commits)
+ head = self.git.head(self.ref)
+ revisions = self.git.revisions(since=self.since, max_count=self.max_commits, ref=self.ref)
settings = json.dumps(
{"since": self.since, "max_commits": self.max_commits}, sort_keys=True
)
with IndexStore(self.path) as store:
previous_head = store.get_meta("head")
stored_engine_version = store.get_meta("engine_version")
- needs_rebuild = rebuild or stored_engine_version != str(ENGINE_VERSION)
+ graph_state = "1" if graph_available() else "0"
+ needs_rebuild = (
+ rebuild
+ or stored_engine_version != str(ENGINE_VERSION)
+ or store.get_meta("graph_enabled") != graph_state
+ )
if previous_head and not self.git.is_ancestor(previous_head, head):
needs_rebuild = True
existing = {str(row[0]) for row in store.rows("SELECT sha FROM commits")}
@@ -131,14 +140,17 @@ def build(self, *, rebuild: bool = False) -> IndexResult:
pending = [revision for revision in revisions if revision not in existing]
self._commit_infos = self.git.commit_infos(pending)
self._changes = self.git.changes_many(pending)
+ self._landed_at = self.git.landed_at_pending(pending, self._commit_infos, self.ref)
self._szz_jobs = []
for sha in pending:
self._index_commit(store, sha)
+ self._index_imports(store, pending)
self._flush_szz(store)
self._rebuild_cochange(store)
store.set_meta("head", head)
store.set_meta("settings", settings)
store.set_meta("engine_version", str(ENGINE_VERSION))
+ store.set_meta("graph_enabled", graph_state)
store.connection.commit()
except Exception:
store.connection.rollback()
@@ -155,13 +167,14 @@ def _index_commit(self, store: IndexStore, sha: str) -> None:
fix = is_fix_message(info.message)
store.connection.execute(
"INSERT INTO commits "
- "(sha, authored_at, committed_at, author_name, author_email, message, is_fix, "
- "is_merge, files_changed, additions, deletions, parents) "
- "VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
+ "(sha, authored_at, committed_at, landed_at, author_name, author_email, message, "
+ "is_fix, is_merge, files_changed, additions, deletions, parents) "
+ "VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
(
sha,
info.authored_at,
info.committed_at,
+ self._landed_at[sha],
info.author_name,
info.author_email,
info.message,
@@ -243,6 +256,26 @@ def _flush_szz(self, store: IndexStore) -> None:
),
)
+ def _index_imports(self, store: IndexStore, pending: list[str]) -> None:
+ """Store optional syntax-tree imports for the source snapshot of each commit."""
+ if not pending or not graph_available():
+ return
+ known_paths = {
+ str(row[0])
+ for row in store.rows("SELECT DISTINCT path FROM file_changes WHERE is_source = 1")
+ }
+ for sha in pending:
+ landed_at = self._landed_at[sha]
+ for change in self._changes.get(sha, []):
+ if not is_source_path(change.path):
+ continue
+ source = "\n".join(self.git.text(sha, change.path))
+ edges = import_edges(change.path, source, known_paths)
+ store.connection.executemany(
+ "INSERT OR IGNORE INTO imports VALUES (?, ?, ?, ?)",
+ ((change.path, target, sha, landed_at) for target in edges),
+ )
+
@staticmethod
def _rebuild_cochange(store: IndexStore) -> None:
store.connection.execute("DELETE FROM cochange")
@@ -255,7 +288,7 @@ def _rebuild_cochange(store: IndexStore) -> None:
pairs: dict[tuple[str, str], tuple[int, str]] = {}
commits = store.rows(
"SELECT f.commit_sha FROM file_changes f JOIN commits c ON c.sha = f.commit_sha "
- "GROUP BY f.commit_sha HAVING COUNT(*) <= 30 ORDER BY c.committed_at, f.commit_sha"
+ "GROUP BY f.commit_sha HAVING COUNT(*) <= 30 ORDER BY c.landed_at, f.commit_sha"
)
for commit in commits:
paths = [
diff --git a/src/devscope/index/store.py b/src/devscope/index/store.py
index af7f26d..45618e9 100644
--- a/src/devscope/index/store.py
+++ b/src/devscope/index/store.py
@@ -9,7 +9,7 @@
from platformdirs import user_cache_path
-SCHEMA_VERSION = 2
+SCHEMA_VERSION = 4
def cache_path(common_git_dir: Path) -> Path:
@@ -48,7 +48,8 @@ def _migrate(self) -> None:
"""
CREATE TABLE commits (
sha TEXT PRIMARY KEY, authored_at INTEGER NOT NULL,
- committed_at INTEGER NOT NULL, author_name TEXT NOT NULL,
+ committed_at INTEGER NOT NULL, landed_at INTEGER NOT NULL,
+ author_name TEXT NOT NULL,
author_email TEXT NOT NULL, message TEXT NOT NULL,
is_fix INTEGER NOT NULL, is_merge INTEGER NOT NULL,
files_changed INTEGER NOT NULL, additions INTEGER NOT NULL,
@@ -75,12 +76,14 @@ def _migrate(self) -> None:
);
CREATE TABLE imports (
path TEXT NOT NULL, imported_path TEXT NOT NULL,
- PRIMARY KEY (path, imported_path)
+ source_commit TEXT NOT NULL, landed_at INTEGER NOT NULL,
+ PRIMARY KEY (path, imported_path, source_commit)
);
CREATE TABLE meta (key TEXT PRIMARY KEY, value TEXT NOT NULL);
CREATE INDEX bug_intro_path_idx ON bug_intro(path);
CREATE INDEX file_changes_path_idx ON file_changes(path);
- PRAGMA user_version = 2;
+ CREATE INDEX imports_target_landed_idx ON imports(imported_path, landed_at);
+ PRAGMA user_version = 4;
"""
)
self.connection.commit()
@@ -89,7 +92,44 @@ def _migrate(self) -> None:
"""
ALTER TABLE commits ADD COLUMN parents TEXT NOT NULL DEFAULT '[]';
ALTER TABLE cochange ADD COLUMN last_sha TEXT NOT NULL DEFAULT '';
- PRAGMA user_version = 2;
+ ALTER TABLE commits ADD COLUMN landed_at INTEGER NOT NULL DEFAULT 0;
+ DROP TABLE imports;
+ CREATE TABLE imports (
+ path TEXT NOT NULL, imported_path TEXT NOT NULL,
+ source_commit TEXT NOT NULL, landed_at INTEGER NOT NULL,
+ PRIMARY KEY (path, imported_path, source_commit)
+ );
+ CREATE INDEX imports_target_landed_idx ON imports(imported_path, landed_at);
+ PRAGMA user_version = 4;
+ """
+ )
+ self.connection.commit()
+ elif version == 2:
+ self.connection.executescript(
+ """
+ ALTER TABLE commits ADD COLUMN landed_at INTEGER NOT NULL DEFAULT 0;
+ DROP TABLE imports;
+ CREATE TABLE imports (
+ path TEXT NOT NULL, imported_path TEXT NOT NULL,
+ source_commit TEXT NOT NULL, landed_at INTEGER NOT NULL,
+ PRIMARY KEY (path, imported_path, source_commit)
+ );
+ CREATE INDEX imports_target_landed_idx ON imports(imported_path, landed_at);
+ PRAGMA user_version = 4;
+ """
+ )
+ self.connection.commit()
+ elif version == 3:
+ self.connection.executescript(
+ """
+ DROP TABLE imports;
+ CREATE TABLE imports (
+ path TEXT NOT NULL, imported_path TEXT NOT NULL,
+ source_commit TEXT NOT NULL, landed_at INTEGER NOT NULL,
+ PRIMARY KEY (path, imported_path, source_commit)
+ );
+ CREATE INDEX imports_target_landed_idx ON imports(imported_path, landed_at);
+ PRAGMA user_version = 4;
"""
)
self.connection.commit()
@@ -107,6 +147,7 @@ def prune_commits(self, shas: set[str]) -> None:
self.connection.executemany("DELETE FROM bug_intro WHERE fix_sha = ?", values)
self.connection.executemany("DELETE FROM file_changes WHERE commit_sha = ?", values)
self.connection.executemany("DELETE FROM commits WHERE sha = ?", values)
+ self.connection.executemany("DELETE FROM imports WHERE source_commit = ?", values)
def get_meta(self, key: str) -> Optional[str]:
row = self.connection.execute("SELECT value FROM meta WHERE key = ?", (key,)).fetchone()
diff --git a/src/devscope/reports.py b/src/devscope/reports.py
index 43b4424..7cad7d3 100644
--- a/src/devscope/reports.py
+++ b/src/devscope/reports.py
@@ -66,6 +66,10 @@ def report_markdown(report: dict[str, Any], repo_url: Optional[str] = None) -> s
"",
f"Merge base `{report['base_commit']}` → head `{report['head_commit']}`",
"",
+ "**uncalibrated weights**"
+ if not report.get("model", {}).get("fitted", False)
+ else "**fitted weights**",
+ "",
f"**{report['new_warnings']} new warnings** · {report['changed_source_files']} changed source files · {report['history']['commits_analyzed']} target-history commits analyzed",
"",
]
@@ -77,7 +81,7 @@ def report_markdown(report: dict[str, Any], repo_url: Optional[str] = None) -> s
lines += [
f"### {index}. {label}",
"",
- f"{item['lines']} lines · touched in {item['recent_commits']} analyzed target-history commits",
+ f"Risk **{item['risk']:.2f}** · {item['calibration']} calibration",
"",
]
if item["findings"]:
@@ -85,14 +89,10 @@ def report_markdown(report: dict[str, Any], repo_url: Optional[str] = None) -> s
f"- **{finding['status']} / {finding['rule']}**: {text(finding['message'])}"
for finding in item["findings"]
]
- else:
- lines.append(
- "- Inspect the changed behavior and its tests; no configured warning was triggered."
- )
- for related in item["related_files"]:
- lines.append(
- f"- Check interactions with {code(related['path'])} ({related['cochanges']} observed co-changes)."
- )
+ lines += [
+ f"- **{text(evidence['kind'])} ({evidence['weight']:+.3f})**: {text(evidence['text'])}"
+ for evidence in item["evidence"]
+ ]
lines.append("")
if not report["checklist"]:
lines += ["No changed source files in the selected scope.", ""]
@@ -107,17 +107,7 @@ def report_markdown(report: dict[str, Any], repo_url: Optional[str] = None) -> s
]
else:
lines += ["Coverage: not supplied; test-file counts are not coverage.", ""]
- lines += [
- "### History-aware hotspots",
- "",
- "Ranked by file lines × observed target-history commits (an attention heuristic).",
- "",
- ]
- lines += [
- f"- {code(item['path'])}: {item['lines']} lines × {item['recent_commits']} commits"
- for item in report.get("history_hotspots", [])
- ]
- lines += ["", "### Package summary", ""]
+ lines += ["### Package summary", ""]
lines += [
f"- {code(item['package'])}: {item['source_files']} source files, {item['changed_source_files']} changed, {item['new_warnings']} new warnings"
for item in report.get("package_summary", [])
@@ -143,7 +133,12 @@ def report_html(report: dict[str, Any], repo_url: Optional[str] = None) -> str:
title = "Demo · " + title
cards = []
if report["kind"] == "review":
- subtitle = f"{report['new_warnings']} new warnings · {report['changed_source_files']} changed source files"
+ weight_status = (
+ "fitted weights"
+ if report.get("model", {}).get("fitted", False)
+ else "uncalibrated weights"
+ )
+ subtitle = f"{report['new_warnings']} new warnings · {report['changed_source_files']} changed source files · {weight_status}"
for item in report["checklist"]:
link = source_link(repo_url, report["head_commit"], item["path"], item["line"])
label = text(item["path"])
@@ -154,11 +149,20 @@ def report_html(report: dict[str, Any], repo_url: Optional[str] = None) -> str:
for finding in item["findings"]
)
details += "".join(
- f"
Review interactions with {text(other['path'])} ({other['cochanges']} co-changes)"
- for other in item["related_files"]
+ f"{text(evidence['kind'])} ({evidence['weight']:+.3f}): {text(evidence['text'])}"
+ for evidence in item["evidence"]
)
+ mitigating = "".join(
+ f"{text(factor['kind'])} ({factor['weight']:+.3f}): {text(factor['text'])}"
+ for factor in item.get("mitigating", [])
+ )
+ if mitigating:
+ details += (
+ "Mitigating factors
"
+ f" "
+ )
cards.append(
- f'{label}
{item["lines"]} lines · {item["recent_commits"]} target-history commits
{details or "- No configured warning; review behavior and tests.
"}
'
+ f'{label}
Risk {item["risk"]:.2f} · {text(item["calibration"])} calibration
'
)
coverage = report["coverage"]
if coverage["available"]:
@@ -170,13 +174,6 @@ def report_html(report: dict[str, Any], repo_url: Optional[str] = None) -> str:
cards.append(
'Coverage not supplied
Test-file counts are not coverage.
'
)
- hotspots = "".join(
- f"{text(item['path'])}: {item['lines']} lines × {item['recent_commits']} target-history commits"
- for item in report.get("history_hotspots", [])
- )
- cards.append(
- f'History-aware hotspots
Ranked by lines × observed commits; review heuristics, not defect predictions.
'
- )
table = "".join(
f'| {text(f["status"])} | {text(f["path"])} | {text(f["rule"])} | {text(f["message"])} |
'
for f in report["findings"]
diff --git a/src/devscope/review.py b/src/devscope/review.py
index 8e31339..3e680e4 100644
--- a/src/devscope/review.py
+++ b/src/devscope/review.py
@@ -5,6 +5,7 @@
import json
import os
import re
+import sqlite3
import tempfile
from collections import Counter
from dataclasses import replace
@@ -15,6 +16,12 @@
from devscope.comparison import _git, extract_snapshot
from devscope.config import ReviewConfig, load_config
from devscope.coverage import read_coverage
+from devscope.graph import graph_available
+from devscope.index.git_reader import GitReader
+from devscope.index.incremental import RepositoryIndexer
+from devscope.risk.evidence import build_evidence
+from devscope.risk.features import pr_features
+from devscope.risk.model import RiskModel
def source_files(
@@ -132,6 +139,44 @@ def changed_lines(repo: Path, base: str, head: str, path: str) -> list[int]:
return sorted(lines)
+def changed_stats(repo: Path, base: str, head: str) -> dict[str, tuple[int, int]]:
+ """Read NUL-safe per-file additions and deletions for the reviewed diff."""
+ raw = _git(repo, "diff", "--numstat", "--no-renames", "-z", base, head, "--")
+ result: dict[str, tuple[int, int]] = {}
+ for record in raw.split(b"\0"):
+ if not record:
+ continue
+ fields = record.split(b"\t", 2)
+ if len(fields) != 3:
+ continue
+ added, deleted, path = fields
+ result[path.decode("utf-8", errors="replace")] = (
+ 0 if added == b"-" else int(added),
+ 0 if deleted == b"-" else int(deleted),
+ )
+ return result
+
+
+def ai_provenance(repo: Path, base: str, head: str) -> dict[str, int]:
+ """Count added lines from AI-trailed or bot-authored commits as context only."""
+ reader = GitReader(repo)
+ revisions = reader.run(repo, "rev-list", f"{base}..{head}").splitlines()
+ infos = reader.commit_infos(revisions)
+ changes = reader.changes_many(revisions)
+ result: Counter[str] = Counter()
+ trailer = re.compile(r"^Co-Authored-By:.*\b(?:Claude|Copilot|Cursor|Codex)\b", re.I | re.M)
+ bot = re.compile(r"(?:\[bot\]|\bbot\b)", re.I)
+ for sha, info in infos.items():
+ if not (
+ trailer.search(info.message)
+ or bot.search(info.author_name)
+ or bot.search(info.author_email)
+ ):
+ continue
+ result.update({change.path: change.additions for change in changes.get(sha, [])})
+ return dict(result)
+
+
def baseline_ids(path: Path) -> set[str]:
data = json.loads(path.read_text(encoding="utf-8"))
if (
@@ -223,10 +268,10 @@ def resolve(ref: str) -> str:
).split(b"\0")
if name
]
- churn, pairs, commits = history(repo, target, config.history_limit)
+ _churn, _pairs, commits = history(repo, target, config.history_limit)
warnings: list[str] = []
coverage: dict[str, Any] = {"available": False}
- coverage_files = {}
+ coverage_files: dict[str, dict[str, Any]] = {}
if coverage_path is not None:
if coverage_commit is None or resolve(coverage_commit) != head_sha:
raise ValueError(
@@ -280,49 +325,83 @@ def resolve(ref: str) -> str:
if item["id"] in old and item["rule"] != "uncovered-added-lines"
else "new"
)
+ stats = changed_stats(repo, branch_point, head_sha)
+ ai_lines = ai_provenance(repo, branch_point, head_sha)
+ author_email = _git(repo, "show", "-s", "--format=%aE", head_sha).decode().strip()
+ indexed = RepositoryIndexer(repo, ref=target).build()
+ ranked: list[tuple[str, Any, Any]] = []
+ changed_set = set(changed)
+ with sqlite3.connect(indexed.path) as database:
+ landed = database.execute(
+ "SELECT landed_at FROM commits WHERE sha = ?", (target,)
+ ).fetchone()
+ if landed is None:
+ raise ValueError("Target revision is outside the indexed history window")
+ as_of = int(landed[0]) + 1
+ model = RiskModel()
+ for path in changed:
+ if path not in head_files:
+ continue
+ additions, deletions = stats.get(path, (0, 0))
+ coverage_item = coverage_files.get(path)
+ uncovered_count: Optional[int] = (
+ len(coverage_item["uncovered"]) if coverage_item is not None else None
+ )
+ features = pr_features(
+ database,
+ path,
+ author_email,
+ changed_set,
+ additions,
+ deletions,
+ as_of=as_of,
+ uncovered=uncovered_count,
+ graph_enabled=graph_available(),
+ )
+ ranked.append((path, features, model.score(features)))
+ ranked.sort(key=lambda item: (-item[2].risk, item[0]))
+ risk_files = [
+ build_evidence(
+ database,
+ path,
+ features,
+ scored,
+ changed_set,
+ as_of=as_of,
+ rank=rank,
+ ai_authored_lines=ai_lines.get(path, 0),
+ additions=stats.get(path, (0, 0))[0],
+ deletions=stats.get(path, (0, 0))[1],
+ )
+ for rank, (path, features, scored) in enumerate(ranked, 1)
+ ]
+
checklist: list[dict[str, Any]] = []
+ risk_by_path = {item["path"]: item for item in risk_files}
for path in changed:
if path not in head_files:
continue
issues = [item for item in findings if item["path"] == path]
- related = sorted(
- (
- (b if a == path else a, count)
- for (a, b), count in pairs.items()
- if path in (a, b) and count >= 2 and (b if a == path else a) in head_files
- ),
- key=lambda pair: (-pair[1], pair[0]),
- )[:3]
+ risk_item = risk_by_path[path]
checklist.append(
{
"path": path,
"line": min(changed_lines(repo, branch_point, head_sha, path) or [1]),
"lines": head_files[path],
- "recent_commits": churn[path],
- "related_files": [
- {"path": name, "cochanges": count} for name, count in related
- ],
+ "risk": risk_item["risk"],
+ "rank": risk_item["rank"],
+ "calibration": risk_item["calibration"],
+ "evidence": risk_item["evidence"],
+ "mitigating": risk_item["mitigating"],
+ "context": risk_item["context"],
+ "recent_commits": 0,
+ "related_files": [],
"findings": issues,
"coverage": coverage_files.get(path),
- "priority": 100 * len(issues)
- + min(churn[path], 50)
- + min(head_files[path] // 100, 40),
+ "priority": risk_item["risk"],
}
)
- checklist.sort(key=lambda item: (-item["priority"], item["path"]))
- hotspot_candidates: list[dict[str, Any]] = [
- {
- "path": path,
- "lines": lines,
- "recent_commits": churn[path],
- "activity_weight": lines * churn[path],
- }
- for path, lines in head_files.items()
- if churn[path] > 0
- ]
- history_hotspots = sorted(
- hotspot_candidates, key=lambda item: (-item["activity_weight"], item["path"])
- )[: config.checklist_limit]
+ checklist.sort(key=lambda item: (item["rank"], item["path"]))
package_summary = [
{
"package": package,
@@ -338,7 +417,7 @@ def resolve(ref: str) -> str:
for package in config.packages
]
return {
- "schema_version": "1.0",
+ "schema_version": 2,
"kind": "review",
"target_commit": target,
"base_commit": branch_point,
@@ -350,7 +429,8 @@ def resolve(ref: str) -> str:
},
"packages": config.packages,
"package_summary": package_summary,
- "history_hotspots": history_hotspots,
+ "risk_files": risk_files,
+ "model": {"fitted": model.fitted},
"changed_source_files": len(checklist),
"checklist": checklist[: config.checklist_limit],
"findings": findings,
@@ -358,10 +438,9 @@ def resolve(ref: str) -> str:
"coverage": coverage,
"warnings": warnings,
"notes": [
- "File size and churn are review heuristics, not defect predictions.",
- "Test-file proximity is not measured coverage.",
+ "Risk v2 uses the repository's point-in-time history before the target revision.",
"Policy and default baseline come from the target commit; renames are treated as remove/add.",
- "History excludes merge commits; co-change evidence ignores commits touching more than 30 files.",
+ "Co-change evidence ignores commits touching more than 30 files.",
"Snapshots omit symlinks and submodules; tracked files remain visible despite ignore/archive attributes.",
],
}
diff --git a/src/devscope/risk/__init__.py b/src/devscope/risk/__init__.py
new file mode 100644
index 0000000..341dee4
--- /dev/null
+++ b/src/devscope/risk/__init__.py
@@ -0,0 +1,13 @@
+"""Leakage-safe risk features backed by the local history index."""
+
+from devscope.risk.features import HistoryFeatures, PRFeatures, history_features, pr_features
+from devscope.risk.model import RiskModel, RiskScore
+
+__all__ = [
+ "HistoryFeatures",
+ "PRFeatures",
+ "RiskModel",
+ "RiskScore",
+ "history_features",
+ "pr_features",
+]
diff --git a/src/devscope/risk/evidence.py b/src/devscope/risk/evidence.py
new file mode 100644
index 0000000..b288031
--- /dev/null
+++ b/src/devscope/risk/evidence.py
@@ -0,0 +1,162 @@
+"""Stable JSON evidence schema for risk-ranked files."""
+
+from __future__ import annotations
+
+import re
+import sqlite3
+from typing import Any
+
+from devscope.risk.features import DAY_SECONDS, PRFeatures, cochange_partners, importer_paths
+from devscope.risk.model import RiskScore
+
+
+def _refs(connection: sqlite3.Connection, path: str, kind: str, as_of: int) -> list[str]:
+ if kind in {"defect_density", "recent_fix_count"}:
+ days = 365 if kind == "defect_density" else 90
+ return [
+ str(row[0])[:7]
+ for row in connection.execute(
+ "SELECT DISTINCT b.fix_sha FROM bug_intro b "
+ "JOIN commits c ON c.sha = b.fix_sha "
+ "WHERE b.path = ? AND c.landed_at >= ? AND c.landed_at < ? "
+ "ORDER BY c.landed_at DESC LIMIT 10",
+ (path, as_of - days * DAY_SECONDS, as_of),
+ )
+ ]
+ return []
+
+
+def owners(connection: sqlite3.Connection, path: str, *, as_of: int) -> list[str]:
+ result: list[str] = []
+ for name, email, _total in connection.execute(
+ "SELECT c.author_name, c.author_email, COUNT(*) AS total FROM file_changes f "
+ "JOIN commits c ON c.sha = f.commit_sha "
+ "WHERE f.path = ? AND c.landed_at < ? GROUP BY c.author_email "
+ "ORDER BY total DESC, c.author_name LIMIT 3",
+ (path, as_of),
+ ):
+ match = re.fullmatch(r"(?:[^+@]+\+)?([^@]+)@users\.noreply\.github\.com", str(email), re.I)
+ result.append(f"@{match.group(1)}" if match else str(name))
+ return result
+
+
+def _defect_count(connection: sqlite3.Connection, path: str, as_of: int) -> int:
+ row = connection.execute(
+ "SELECT COUNT(DISTINCT b.fix_sha) FROM bug_intro b "
+ "JOIN commits c ON c.sha = b.fix_sha "
+ "WHERE b.path = ? AND c.landed_at >= ? AND c.landed_at < ?",
+ (path, as_of - 365 * DAY_SECONDS, as_of),
+ ).fetchone()
+ return int(row[0]) if row else 0
+
+
+def build_evidence(
+ connection: sqlite3.Connection,
+ path: str,
+ features: PRFeatures,
+ scored: RiskScore,
+ changed_paths: set[str],
+ *,
+ as_of: int,
+ rank: int,
+ ai_authored_lines: int = 0,
+ additions: int = 0,
+ deletions: int = 0,
+) -> dict[str, Any]:
+ """Build the spec evidence object; low-risk files deliberately show score only."""
+ result: dict[str, Any] = {
+ "path": path,
+ "risk": round(scored.risk, 2),
+ "rank": rank,
+ "calibration": scored.calibration,
+ "evidence": [],
+ "mitigating": [],
+ "context": {
+ "ai_authored_lines": ai_authored_lines,
+ "owners": owners(connection, path, as_of=as_of),
+ },
+ }
+ if scored.risk < 0.2:
+ result["evidence"] = []
+ result["mitigating"] = []
+ result["context"] = {}
+ return result
+ missing = [
+ item
+ for item in cochange_partners(
+ connection, path, as_of=as_of, min_support=3, min_confidence=0.5
+ )
+ if item.partner not in changed_paths
+ ]
+ importers = importer_paths(connection, path, as_of=as_of)
+ defect_refs = _refs(connection, path, "defect_density", as_of)
+ defect_count = _defect_count(connection, path, as_of)
+ texts: dict[str, tuple[str, list[str]]] = {
+ "defect_density": (
+ f"{defect_count} bug fixes traced to this file in 12 months",
+ defect_refs,
+ ),
+ "recent_fix_count": (
+ f"{features.recent_fix_count} bug fixes landed in the last 90 days",
+ _refs(connection, path, "recent_fix_count", as_of),
+ ),
+ "churn_90d": (
+ f"~{round(features.churn_90d)} lines changed here in the last 90 days "
+ "(recent changes weighted higher)",
+ [],
+ ),
+ "distinct_authors_12m": (
+ f"{features.distinct_authors_12m} authors changed this file in 12 months",
+ [],
+ ),
+ "author_prior_commits": (
+ "Author's first change to this file"
+ if features.author_prior_commits == 0
+ else f"Author has {features.author_prior_commits} prior commits to this file",
+ [],
+ ),
+ "lines_changed": (
+ f"PR changes +{additions}/−{deletions} lines in this file",
+ [path],
+ ),
+ "missing_cochange": (
+ f"{missing[0].partner} changed with this file in {missing[0].support} commits; not in this diff"
+ if missing
+ else f"{features.missing_cochange:.2f} missing co-change confidence",
+ [item.partner for item in missing],
+ ),
+ "blast_radius": (f"{features.blast_radius} importers within depth 2", importers or []),
+ "uncovered_added_lines": (
+ f"{features.uncovered_added_lines} added executable lines are uncovered",
+ [path],
+ ),
+ }
+ kinds = {
+ "defect_density": "defect_history",
+ "recent_fix_count": "recent_fixes",
+ "churn_90d": "churn",
+ "distinct_authors_12m": "ownership",
+ "author_prior_commits": "first_touch",
+ "lines_changed": "change_size",
+ "missing_cochange": "missing_cochange",
+ "blast_radius": "blast_radius",
+ "uncovered_added_lines": "uncovered_added_lines",
+ }
+ for name, contribution in sorted(
+ scored.contributions.items(), key=lambda item: (-abs(item[1]), item[0])
+ ):
+ value = getattr(features, name)
+ evidence_value = 1 if name == "author_prior_commits" and value == 0 else value
+ if evidence_value is None or evidence_value == 0 or abs(contribution) < 1e-12:
+ continue
+ sentence, refs = texts[name]
+ item: dict[str, Any] = {
+ "kind": kinds[name],
+ "weight": round(contribution, 4),
+ "text": sentence,
+ }
+ if refs:
+ item["refs"] = refs
+ key = "evidence" if contribution > 0 else "mitigating"
+ result[key].append(item)
+ return result
diff --git a/src/devscope/risk/features.py b/src/devscope/risk/features.py
new file mode 100644
index 0000000..efbab28
--- /dev/null
+++ b/src/devscope/risk/features.py
@@ -0,0 +1,324 @@
+"""Point-in-time risk features with no wall-clock reads."""
+
+from __future__ import annotations
+
+import json
+import math
+import sqlite3
+from dataclasses import dataclass
+
+DAY_SECONDS = 86_400
+
+
+@dataclass(frozen=True)
+class CochangeEvidence:
+ """One point-in-time co-change relationship."""
+
+ partner: str
+ support: int
+ confidence: float
+ last_sha: str
+
+
+@dataclass(frozen=True)
+class HistoryFeatures:
+ """History-backed inputs for the risk model at one timestamp."""
+
+ defect_density: float
+ recent_fix_count: int
+ churn_90d: float
+ distinct_authors_12m: int
+ author_prior_commits: int
+ missing_cochange: float
+
+
+@dataclass(frozen=True)
+class PRFeatures:
+ """The nine model inputs for one changed file."""
+
+ defect_density: float
+ recent_fix_count: int
+ churn_90d: float
+ distinct_authors_12m: int
+ author_prior_commits: int
+ lines_changed: float
+ missing_cochange: float
+ blast_radius: int | None
+ uncovered_added_lines: int | None
+
+
+def _validate_as_of(as_of: int) -> None:
+ if as_of < 0:
+ raise ValueError("as_of must be a non-negative Unix timestamp")
+
+
+def _decay(event_timestamp: int, as_of: int, half_life_days: int) -> float:
+ age = max(0, as_of - event_timestamp)
+ return float(0.5 ** (age / (half_life_days * DAY_SECONDS)))
+
+
+def defect_density(
+ connection: sqlite3.Connection,
+ path: str,
+ *,
+ as_of: int,
+ half_life_days: int = 180,
+) -> float:
+ """Return decayed SZZ lines divided by decayed touched lines at ``as_of``."""
+ _validate_as_of(as_of)
+ if half_life_days <= 0:
+ raise ValueError("half_life_days must be positive")
+ defect_lines = 0.0
+ for lines, landed_at in connection.execute(
+ "SELECT b.lines, c.landed_at FROM bug_intro b "
+ "JOIN commits c ON c.sha = b.fix_sha "
+ "WHERE b.path = ? AND c.landed_at < ?",
+ (path, as_of),
+ ):
+ parsed = json.loads(str(lines))
+ defect_lines += len(parsed) * _decay(int(landed_at), as_of, half_life_days)
+
+ touched_lines = 0.0
+ for additions, deletions, landed_at in connection.execute(
+ "SELECT f.additions, f.deletions, c.landed_at "
+ "FROM file_changes f JOIN commits c ON c.sha = f.commit_sha "
+ "WHERE f.path = ? AND c.landed_at < ?",
+ (path, as_of),
+ ):
+ touched_lines += (int(additions) + int(deletions)) * _decay(
+ int(landed_at), as_of, half_life_days
+ )
+ return defect_lines / max(1.0, touched_lines)
+
+
+def recent_fix_count(
+ connection: sqlite3.Connection, path: str, *, as_of: int, window_days: int = 90
+) -> int:
+ """Count distinct SZZ fixes in the trailing window at ``as_of``."""
+ _validate_as_of(as_of)
+ cutoff = as_of - window_days * DAY_SECONDS
+ row = connection.execute(
+ "SELECT COUNT(DISTINCT b.fix_sha) FROM bug_intro b "
+ "JOIN commits c ON c.sha = b.fix_sha "
+ "WHERE b.path = ? AND c.landed_at >= ? AND c.landed_at < ?",
+ (path, cutoff, as_of),
+ ).fetchone()
+ return int(row[0]) if row else 0
+
+
+def churn_90d(connection: sqlite3.Connection, path: str, *, as_of: int) -> float:
+ """Return recency-decayed line churn from the prior 90 days."""
+ _validate_as_of(as_of)
+ cutoff = as_of - 90 * DAY_SECONDS
+ churn = 0.0
+ for additions, deletions, landed_at in connection.execute(
+ "SELECT f.additions, f.deletions, c.landed_at "
+ "FROM file_changes f JOIN commits c ON c.sha = f.commit_sha "
+ "WHERE f.path = ? AND c.landed_at >= ? AND c.landed_at < ?",
+ (path, cutoff, as_of),
+ ):
+ churn += (int(additions) + int(deletions)) * _decay(int(landed_at), as_of, 90)
+ return churn
+
+
+def distinct_authors_12m(connection: sqlite3.Connection, path: str, *, as_of: int) -> int:
+ """Count distinct authors in the 12 months ending at ``as_of``."""
+ _validate_as_of(as_of)
+ cutoff = as_of - 365 * DAY_SECONDS
+ row = connection.execute(
+ "SELECT COUNT(DISTINCT c.author_email) "
+ "FROM file_changes f JOIN commits c ON c.sha = f.commit_sha "
+ "WHERE f.path = ? AND c.landed_at >= ? AND c.landed_at < ?",
+ (path, cutoff, as_of),
+ ).fetchone()
+ return int(row[0]) if row else 0
+
+
+def author_prior_commits(
+ connection: sqlite3.Connection, path: str, author_email: str, *, as_of: int
+) -> int:
+ """Count the author's commits to a file no later than ``as_of``."""
+ _validate_as_of(as_of)
+ row = connection.execute(
+ "SELECT COUNT(DISTINCT c.sha) "
+ "FROM file_changes f JOIN commits c ON c.sha = f.commit_sha "
+ "WHERE f.path = ? AND c.author_email = ? AND c.landed_at < ?",
+ (path, author_email, as_of),
+ ).fetchone()
+ return int(row[0]) if row else 0
+
+
+def cochange_partners(
+ connection: sqlite3.Connection,
+ path: str,
+ *,
+ as_of: int,
+ min_support: int = 1,
+ min_confidence: float = 0.0,
+) -> list[CochangeEvidence]:
+ """Compute point-in-time co-change confidence without reading future commits."""
+ _validate_as_of(as_of)
+ denominator_row = connection.execute(
+ "SELECT COUNT(DISTINCT f.commit_sha) "
+ "FROM file_changes f JOIN commits c ON c.sha = f.commit_sha "
+ "WHERE f.path = ? AND f.is_source = 1 AND c.landed_at < ?",
+ (path, as_of),
+ ).fetchone()
+ denominator = int(denominator_row[0]) if denominator_row else 0
+ if denominator == 0:
+ return []
+
+ rows = connection.execute(
+ "SELECT f1.commit_sha, c.landed_at, f2.path "
+ "FROM file_changes f1 "
+ "JOIN file_changes f2 ON f2.commit_sha = f1.commit_sha AND f2.path != f1.path "
+ "JOIN commits c ON c.sha = f1.commit_sha "
+ "WHERE f1.path = ? AND f1.is_source = 1 AND f2.is_source = 1 "
+ "AND c.files_changed <= 30 AND c.landed_at < ? "
+ "ORDER BY c.landed_at, f1.commit_sha, f2.path",
+ (path, as_of),
+ )
+ commits_by_partner: dict[str, set[str]] = {}
+ last_by_partner: dict[str, str] = {}
+ for commit_sha, _landed_at, partner in rows:
+ partner_text = str(partner)
+ commits_by_partner.setdefault(partner_text, set()).add(str(commit_sha))
+ last_by_partner[partner_text] = str(commit_sha)
+
+ evidence: list[CochangeEvidence] = []
+ for partner, commits in commits_by_partner.items():
+ support = len(commits)
+ confidence = support / denominator
+ if support >= min_support and confidence >= min_confidence:
+ evidence.append(
+ CochangeEvidence(partner, support, confidence, last_by_partner[partner])
+ )
+ return sorted(evidence, key=lambda item: (-item.confidence, -item.support, item.partner))
+
+
+def missing_cochange_score(
+ connection: sqlite3.Connection,
+ path: str,
+ changed_paths: set[str],
+ *,
+ as_of: int,
+ min_support: int = 3,
+ min_confidence: float = 0.5,
+) -> float:
+ """Sum confidence for established partners missing from the proposed change."""
+ _validate_as_of(as_of)
+ return sum(
+ item.confidence
+ for item in cochange_partners(
+ connection,
+ path,
+ as_of=as_of,
+ min_support=min_support,
+ min_confidence=min_confidence,
+ )
+ if item.partner not in changed_paths
+ )
+
+
+def log_lines_changed(additions: int, deletions: int, *, as_of: int) -> float:
+ """Return the log-scaled PR size feature at the explicit evaluation time."""
+ _validate_as_of(as_of)
+ return math.log1p(max(0, additions) + max(0, deletions))
+
+
+def blast_radius(importer_count: int | None, *, as_of: int) -> int | None:
+ """Return optional import-graph reach without substituting zero for missing graphs."""
+ _validate_as_of(as_of)
+ return None if importer_count is None else max(0, importer_count)
+
+
+def uncovered_added_lines(value: int | None, *, as_of: int) -> int | None:
+ """Return optional coverage evidence without substituting zero when unavailable."""
+ _validate_as_of(as_of)
+ return None if value is None else max(0, value)
+
+
+def importer_paths(
+ connection: sqlite3.Connection, path: str, *, as_of: int, max_depth: int = 2
+) -> list[str] | None:
+ """Return unique point-in-time importers through ``max_depth`` hops."""
+ _validate_as_of(as_of)
+ if max_depth < 1:
+ raise ValueError("max_depth must be positive")
+ table = connection.execute(
+ "SELECT 1 FROM sqlite_master WHERE type = 'table' AND name = 'imports'"
+ ).fetchone()
+ columns = {str(row[1]) for row in connection.execute("PRAGMA table_info(imports)").fetchall()}
+ if table is None or "landed_at" not in columns:
+ return None
+ seen = {path}
+ frontier = {path}
+ importers: set[str] = set()
+ for _depth in range(max_depth):
+ if not frontier:
+ break
+ placeholders = ",".join("?" for _item in frontier)
+ rows = connection.execute(
+ "SELECT DISTINCT i.path FROM imports i "
+ "WHERE i.source_commit = ("
+ " SELECT f.commit_sha FROM file_changes f "
+ " JOIN commits c ON c.sha = f.commit_sha "
+ " WHERE f.path = i.path AND c.landed_at < ? "
+ " ORDER BY c.landed_at DESC, c.sha DESC LIMIT 1"
+ ") "
+ f"AND i.imported_path IN ({placeholders}) AND i.landed_at < ?",
+ (as_of, *sorted(frontier), as_of),
+ )
+ next_frontier = {str(row[0]) for row in rows}.difference(seen)
+ importers.update(next_frontier)
+ seen.update(next_frontier)
+ frontier = next_frontier
+ return sorted(importers)
+
+
+def pr_features(
+ connection: sqlite3.Connection,
+ path: str,
+ author_email: str,
+ changed_paths: set[str],
+ additions: int,
+ deletions: int,
+ *,
+ as_of: int,
+ uncovered: int | None = None,
+ graph_enabled: bool = True,
+) -> PRFeatures:
+ """Compute all model features for a changed file at an explicit landing boundary."""
+ history = history_features(connection, path, author_email, changed_paths, as_of=as_of)
+ importers = importer_paths(connection, path, as_of=as_of) if graph_enabled else None
+ return PRFeatures(
+ defect_density=history.defect_density,
+ recent_fix_count=history.recent_fix_count,
+ churn_90d=history.churn_90d,
+ distinct_authors_12m=history.distinct_authors_12m,
+ author_prior_commits=history.author_prior_commits,
+ lines_changed=log_lines_changed(additions, deletions, as_of=as_of),
+ missing_cochange=history.missing_cochange,
+ blast_radius=blast_radius(None if importers is None else len(importers), as_of=as_of),
+ uncovered_added_lines=uncovered_added_lines(uncovered, as_of=as_of),
+ )
+
+
+def history_features(
+ connection: sqlite3.Connection,
+ path: str,
+ author_email: str,
+ changed_paths: set[str],
+ *,
+ as_of: int,
+) -> HistoryFeatures:
+ """Build all history-backed model inputs through the point-in-time query path."""
+ _validate_as_of(as_of)
+ return HistoryFeatures(
+ defect_density=defect_density(connection, path, as_of=as_of),
+ recent_fix_count=recent_fix_count(connection, path, as_of=as_of),
+ churn_90d=churn_90d(connection, path, as_of=as_of),
+ distinct_authors_12m=distinct_authors_12m(connection, path, as_of=as_of),
+ author_prior_commits=author_prior_commits(connection, path, author_email, as_of=as_of),
+ missing_cochange=missing_cochange_score(connection, path, changed_paths, as_of=as_of),
+ )
diff --git a/src/devscope/risk/model.py b/src/devscope/risk/model.py
new file mode 100644
index 0000000..94aad41
--- /dev/null
+++ b/src/devscope/risk/model.py
@@ -0,0 +1,58 @@
+"""Small, inspectable logistic risk model with global placeholder weights."""
+
+from __future__ import annotations
+
+import json
+import math
+from dataclasses import asdict, dataclass
+from importlib.resources import files
+from typing import Any, cast
+
+from devscope.risk.features import PRFeatures
+
+
+@dataclass(frozen=True)
+class RiskScore:
+ risk: float
+ raw: float
+ calibration: str
+ contributions: dict[str, float]
+
+
+class RiskModel:
+ """A loaded global model; P3 will fit and calibrate its weights."""
+
+ def __init__(self) -> None:
+ self.config = load_weights()
+ self.fitted = bool(self.config["fitted"])
+
+ def score(self, features: PRFeatures) -> RiskScore:
+ values = asdict(features)
+ contributions: dict[str, float] = {}
+ for name, weight in self.config["weights"].items():
+ value = values[name]
+ if value is None:
+ continue
+ stats = self.config["standardization"][name]
+ contributions[name] = float(weight) * (float(value) - stats["mean"]) / stats["scale"]
+ raw = float(self.config["intercept"]) + sum(contributions.values())
+ return RiskScore(round(_sigmoid(raw), 6), raw, "global", contributions)
+
+
+def _sigmoid(value: float) -> float:
+ if value >= 0:
+ return 1.0 / (1.0 + math.exp(-value))
+ exp = math.exp(value)
+ return exp / (1.0 + exp)
+
+
+def load_weights() -> dict[str, Any]:
+ return cast(
+ dict[str, Any],
+ json.loads(files("devscope.risk").joinpath("weights.json").read_text(encoding="utf-8")),
+ )
+
+
+def score(features: PRFeatures) -> RiskScore:
+ """Compatibility wrapper for scoring one file."""
+ return RiskModel().score(features)
diff --git a/src/devscope/risk/weights.json b/src/devscope/risk/weights.json
new file mode 100644
index 0000000..a106d4c
--- /dev/null
+++ b/src/devscope/risk/weights.json
@@ -0,0 +1,26 @@
+{
+ "fitted": false,
+ "intercept": 0.0,
+ "weights": {
+ "defect_density": 1.1,
+ "recent_fix_count": 0.5,
+ "churn_90d": 0.35,
+ "distinct_authors_12m": 0.2,
+ "author_prior_commits": -0.3,
+ "lines_changed": 0.45,
+ "missing_cochange": 0.65,
+ "blast_radius": 0.25,
+ "uncovered_added_lines": 0.4
+ },
+ "standardization": {
+ "defect_density": {"mean": 0.02, "scale": 0.08},
+ "recent_fix_count": {"mean": 0.5, "scale": 1.5},
+ "churn_90d": {"mean": 75.0, "scale": 180.0},
+ "distinct_authors_12m": {"mean": 2.0, "scale": 2.0},
+ "author_prior_commits": {"mean": 3.0, "scale": 6.0},
+ "lines_changed": {"mean": 2.5, "scale": 1.5},
+ "missing_cochange": {"mean": 0.1, "scale": 0.4},
+ "blast_radius": {"mean": 2.0, "scale": 6.0},
+ "uncovered_added_lines": {"mean": 1.0, "scale": 5.0}
+ }
+}
diff --git a/tests/golden/risk_evidence_v2.json b/tests/golden/risk_evidence_v2.json
new file mode 100644
index 0000000..d686c6d
--- /dev/null
+++ b/tests/golden/risk_evidence_v2.json
@@ -0,0 +1,20 @@
+[
+ {
+ "calibration": "global",
+ "context": {"ai_authored_lines": 2, "owners": ["Alice Example"]},
+ "evidence": [
+ {"kind": "missing_cochange", "refs": ["billing/models.py"], "text": "billing/models.py changed with this file in 4 commits; not in this diff", "weight": 1.1375},
+ {"kind": "defect_history", "refs": ["ee44629"], "text": "1 bug fixes traced to this file in 12 months", "weight": 1.1},
+ {"kind": "recent_fixes", "refs": ["ee44629"], "text": "1 bug fixes landed in the last 90 days", "weight": 0.1667}
+ ],
+ "mitigating": [
+ {"kind": "change_size", "refs": ["billing/service.py"], "text": "PR changes +2/−1 lines in this file", "weight": -0.3341},
+ {"kind": "churn", "text": "~10 lines changed here in the last 90 days (recent changes weighted higher)", "weight": -0.1264},
+ {"kind": "ownership", "text": "1 authors changed this file in 12 months", "weight": -0.1},
+ {"kind": "first_touch", "text": "Author has 5 prior commits to this file", "weight": -0.1}
+ ],
+ "path": "billing/service.py",
+ "rank": 1,
+ "risk": 0.85
+ }
+]
diff --git a/tests/test_history_index.py b/tests/test_history_index.py
index 3a141a3..3c895d4 100644
--- a/tests/test_history_index.py
+++ b/tests/test_history_index.py
@@ -8,11 +8,13 @@
from pathlib import Path
from typing import Any
+import pytest
from click.testing import CliRunner
from devscope.cli import cli
from devscope.index.git_reader import GitError, GitReader
from devscope.index.incremental import ENGINE_VERSION, RepositoryIndexer
+from devscope.risk.features import cochange_partners, defect_density
from devscope.szz.filters import is_ignored_line, is_test_path
from devscope.szz.fix_detector import is_fix_message
@@ -255,6 +257,9 @@ def test_mass_change_intro_commit_is_excluded(tmp_path: Path, monkeypatch: Any)
result = RepositoryIndexer(repo, max_workers=1).build()
assert result.bug_intro_rows == 0
+ as_of = int(git(repo, "show", "-s", "--format=%ct", "HEAD")) + 1
+ with sqlite3.connect(result.path) as database:
+ assert defect_density(database, "module_0.py", as_of=as_of) == 0.0
def test_renamed_and_fixed_file_keeps_precise_hunk(tmp_path: Path, monkeypatch: Any) -> None:
@@ -312,9 +317,12 @@ def test_sliding_window_matches_fresh_cold_index(tmp_path: Path, monkeypatch: An
(repo / "alpha.py").write_text("VALUE = 3\n")
commit(repo, "update alpha")
- def snapshot(cache_name: str) -> tuple[list[tuple[Any, ...]], list[tuple[Any, ...]]]:
+ def snapshot(
+ cache_name: str,
+ ) -> tuple[list[tuple[Any, ...]], list[tuple[Any, ...]], list[tuple[Any, ...]]]:
monkeypatch.setenv("DEVSCOPE_CACHE_DIR", str(tmp_path / cache_name))
result = RepositoryIndexer(repo, max_commits=5, max_workers=1).build()
+ as_of = int(git(repo, "show", "-s", "--format=%ct", "HEAD"))
with sqlite3.connect(result.path) as database:
bug_rows = database.execute(
"SELECT intro_sha, fix_sha, path, intro_path, lines, intro_ts, fix_ts "
@@ -324,7 +332,11 @@ def snapshot(cache_name: str) -> tuple[list[tuple[Any, ...]], list[tuple[Any, ..
"SELECT path, partner, support, confidence, last_sha "
"FROM cochange ORDER BY path, partner"
).fetchall()
- return bug_rows, cochange_rows
+ risk_cochange_rows = [
+ (item.partner, item.support, item.confidence, item.last_sha)
+ for item in cochange_partners(database, "alpha.py", as_of=as_of)
+ ]
+ return bug_rows, cochange_rows, risk_cochange_rows
incremental_cache = "incremental-cache"
initial = snapshot(incremental_cache)
@@ -343,3 +355,95 @@ def snapshot(cache_name: str) -> tuple[list[tuple[Any, ...]], list[tuple[Any, ..
cold_after_fix_expires = snapshot("cold-cache-fix-expired")
assert incremental_after_fix_expires == cold_after_fix_expires
assert incremental_after_fix_expires[0] == []
+
+
+def test_single_commit_incremental_git_calls_do_not_scale_with_existing_merges(
+ tmp_path: Path, monkeypatch: Any
+) -> None:
+ call_counts: list[int] = []
+ for merge_count in (1, 6):
+ case = tmp_path / f"case-{merge_count}"
+ case.mkdir()
+ repo = repository(case)
+ main_branch = git(repo, "branch", "--show-current")
+ (repo / "base.py").write_text("BASE = 1\n")
+ commit(repo, "base")
+ for number in range(merge_count):
+ branch = f"feature-{number}"
+ git(repo, "switch", "-c", branch)
+ (repo / f"feature_{number}.py").write_text(f"VALUE = {number}\n")
+ commit(repo, f"feature {number}")
+ git(repo, "switch", main_branch)
+ git(repo, "merge", "--no-ff", branch, "-m", f"merge feature {number}")
+
+ cache = tmp_path / f"cache-{merge_count}"
+ monkeypatch.setenv("DEVSCOPE_CACHE_DIR", str(cache))
+ RepositoryIndexer(repo, since="10 years ago", max_workers=1).build()
+ (repo / "latest.py").write_text("LATEST = 1\n")
+ commit(repo, "one new mainline commit")
+
+ indexer = RepositoryIndexer(repo, since="10 years ago", max_workers=1)
+ original_run = indexer.git.run
+ calls: list[tuple[str, ...]] = []
+
+ def counted_run(
+ cwd: Path,
+ *args: str,
+ input_text: str | None = None,
+ _calls: list[tuple[str, ...]] = calls,
+ _original: Any = original_run,
+ ) -> str:
+ _calls.append(args)
+ return _original(cwd, *args, input_text=input_text)
+
+ monkeypatch.setattr(indexer.git, "run", counted_run)
+ result = indexer.build()
+ assert result.indexed_commits == 1
+ assert not result.rebuilt
+ assert not [
+ args
+ for args in calls
+ if len(args) > 1 and args[0] == "rev-list" and args[1].startswith("^")
+ ]
+ call_counts.append(len(calls))
+
+ assert call_counts == [6, 6]
+
+
+def test_target_ref_does_not_rebuild_when_switching_feature_branches(
+ tmp_path: Path, monkeypatch: Any
+) -> None:
+ repo = repository(tmp_path)
+ monkeypatch.setenv("DEVSCOPE_CACHE_DIR", str(tmp_path / "cache"))
+ (repo / "base.py").write_text("BASE = 1\n")
+ commit(repo, "base")
+ base_branch = git(repo, "branch", "--show-current")
+
+ git(repo, "switch", "-c", "feature-one")
+ (repo / "one.py").write_text("ONE = 1\n")
+ commit(repo, "feature one")
+ first = RepositoryIndexer(repo, ref=base_branch, max_workers=1).build()
+
+ git(repo, "switch", base_branch)
+ git(repo, "switch", "-c", "feature-two")
+ (repo / "two.py").write_text("TWO = 2\n")
+ commit(repo, "feature two")
+ second = RepositoryIndexer(repo, ref=base_branch, max_workers=1).build()
+
+ assert first.total_commits == second.total_commits == 1
+ assert second.indexed_commits == 0
+ assert not second.rebuilt
+
+
+def test_promisor_remote_failure_suggests_full_clone(tmp_path: Path, monkeypatch: Any) -> None:
+ class FailedCommand:
+ returncode = 128
+ stdout = ""
+ stderr = "fatal: could not fetch object from promisor remote"
+
+ def failed_run(*_args: object, **_kwargs: object) -> FailedCommand:
+ return FailedCommand()
+
+ monkeypatch.setattr(subprocess, "run", failed_run)
+ with pytest.raises(GitError, match=r"full clone.*git fetch --refetch"):
+ GitReader.run(tmp_path, "show", "HEAD:file.py")
diff --git a/tests/test_review_tools.py b/tests/test_review_tools.py
index 6d0cab4..dba10c8 100644
--- a/tests/test_review_tools.py
+++ b/tests/test_review_tools.py
@@ -69,6 +69,26 @@ def test_existing_findings_do_not_fail_gate_and_baselines_are_stable(repository:
assert output.exit_code == 0, output.output
+def test_review_features_exclude_the_prs_own_commits(
+ repository: Path, monkeypatch: pytest.MonkeyPatch
+) -> None:
+ root = repository
+ monkeypatch.setenv("DEVSCOPE_CACHE_DIR", str(root.parent / "review-cache"))
+ base = git(root, "rev-parse", "HEAD")
+ git(root, "config", "user.name", "Feature Author")
+ git(root, "config", "user.email", "feature@example.com")
+ (root / "app.py").write_text("pass\n" * 4)
+ commit(root, "first PR commit")
+ (root / "app.py").write_text("pass\n" * 5)
+ commit(root, "second PR commit")
+
+ report = review_repository(root, base)
+ evidence = report["risk_files"][0]["evidence"]
+ first_touch = next(item for item in evidence if item["kind"] == "first_touch")
+ assert first_touch["text"] == "Author's first change to this file"
+ assert report["risk_files"][0]["context"]["owners"] == ["Test"]
+
+
def test_history_and_cochanges_preserve_unusual_paths(repository: Path) -> None:
root = repository
name = "space \nünicode.py"
@@ -263,13 +283,15 @@ def test_cobertura_sources_resolve_to_repository_paths(tmp_path: Path) -> None:
read_coverage(report, "/different/repo")
-def test_package_paths_normalize_and_history_hotspots_are_present(repository: Path) -> None:
+def test_package_paths_normalize_and_legacy_hotspots_are_removed(repository: Path) -> None:
assert read_config({"packages": ["./packages/api/"]}).packages == ["packages/api"]
report = review_repository(repository, "HEAD")
- assert report["history_hotspots"][0]["path"] == "app.py"
- assert report["history_hotspots"][0]["recent_commits"] == 1
- assert "History-aware hotspots" in report_markdown(report)
- assert "History-aware hotspots" in report_html(report)
+ assert report["schema_version"] == 2
+ assert "history_hotspots" not in report
+ assert "History-aware hotspots" not in report_markdown(report)
+ assert "History-aware hotspots" not in report_html(report)
+ assert "uncalibrated weights" in report_markdown(report)
+ assert "uncalibrated weights" in report_html(report)
def test_scans_detect_modern_python_dependencies_and_package_manifests(tmp_path: Path) -> None:
diff --git a/tests/test_risk_features.py b/tests/test_risk_features.py
new file mode 100644
index 0000000..859cd4a
--- /dev/null
+++ b/tests/test_risk_features.py
@@ -0,0 +1,242 @@
+"""Point-in-time feature tests for leakage-free historical replay."""
+
+from __future__ import annotations
+
+import inspect
+import os
+import sqlite3
+import subprocess
+from pathlib import Path
+from typing import Any
+
+from devscope.index.git_reader import GitReader
+from devscope.index.incremental import RepositoryIndexer
+from devscope.risk.features import (
+ author_prior_commits,
+ blast_radius,
+ churn_90d,
+ cochange_partners,
+ defect_density,
+ distinct_authors_12m,
+ history_features,
+ importer_paths,
+ log_lines_changed,
+ missing_cochange_score,
+ pr_features,
+ recent_fix_count,
+ uncovered_added_lines,
+)
+
+
+def git(repo: Path, *args: str) -> str:
+ completed = subprocess.run(["git", *args], cwd=repo, text=True, capture_output=True, check=True)
+ return completed.stdout.strip()
+
+
+def commit_at(repo: Path, message: str, timestamp: int) -> str:
+ git(repo, "add", ".")
+ environment = os.environ.copy()
+ date = f"@{timestamp} +0000"
+ environment.update({"GIT_AUTHOR_DATE": date, "GIT_COMMITTER_DATE": date})
+ subprocess.run(
+ ["git", "commit", "-m", message],
+ cwd=repo,
+ env=environment,
+ text=True,
+ capture_output=True,
+ check=True,
+ )
+ return git(repo, "rev-parse", "HEAD")
+
+
+def merge_at(repo: Path, branch: str, message: str, timestamp: int) -> str:
+ environment = os.environ.copy()
+ date = f"@{timestamp} +0000"
+ environment.update({"GIT_AUTHOR_DATE": date, "GIT_COMMITTER_DATE": date})
+ subprocess.run(
+ ["git", "merge", "--no-ff", branch, "-m", message],
+ cwd=repo,
+ env=environment,
+ text=True,
+ capture_output=True,
+ check=True,
+ )
+ return git(repo, "rev-parse", "HEAD")
+
+
+def repository(tmp_path: Path) -> Path:
+ repo = tmp_path / "repo"
+ repo.mkdir()
+ git(repo, "init", "-q")
+ git(repo, "config", "user.name", "Devscope Test")
+ git(repo, "config", "user.email", "devscope@example.com")
+ return repo
+
+
+def test_every_public_feature_requires_explicit_as_of() -> None:
+ functions = [
+ defect_density,
+ recent_fix_count,
+ churn_90d,
+ distinct_authors_12m,
+ author_prior_commits,
+ cochange_partners,
+ missing_cochange_score,
+ log_lines_changed,
+ blast_radius,
+ uncovered_added_lines,
+ history_features,
+ importer_paths,
+ pr_features,
+ ]
+ for function in functions:
+ parameter = inspect.signature(function).parameters["as_of"]
+ assert parameter.default is inspect.Parameter.empty
+ assert parameter.kind is inspect.Parameter.KEYWORD_ONLY
+
+
+def test_features_at_as_of_match_index_truncated_at_same_time(
+ tmp_path: Path, monkeypatch: Any
+) -> None:
+ repo = repository(tmp_path)
+ base = 1_780_000_000
+ source = repo / "main.py"
+ peer = repo / "peer.py"
+ source.write_text("VALUE = 'wrong'\n")
+ peer.write_text("PEER = 1\n")
+ commit_at(repo, "introduce wrong value", base)
+ source.write_text("VALUE = 'right'\n")
+ commit_at(repo, "fix wrong value bug", base + 100)
+ source.write_text("VALUE = 'right'\nCOUNT = 1\n")
+ peer.write_text("PEER = 2\n")
+ commit_at(repo, "update paired files", base + 200)
+ as_of = base + 200
+
+ monkeypatch.setenv("DEVSCOPE_CACHE_DIR", str(tmp_path / "truncated-cache"))
+ truncated = RepositoryIndexer(repo, since="10 years ago", max_workers=1).build()
+
+ source.write_text("VALUE = 'right'\nCOUNT = 2\n")
+ peer.write_text("PEER = 3\n")
+ commit_at(repo, "future paired update", base + 300)
+ source.write_text("VALUE = 'future wrong'\nCOUNT = 2\n")
+ commit_at(repo, "introduce future failure", base + 400)
+ source.write_text("VALUE = 'right'\nCOUNT = 2\n")
+ commit_at(repo, "fix future regression bug", base + 500)
+
+ monkeypatch.setenv("DEVSCOPE_CACHE_DIR", str(tmp_path / "full-cache"))
+ full = RepositoryIndexer(repo, since="10 years ago", max_workers=1).build()
+
+ with sqlite3.connect(truncated.path) as truncated_db, sqlite3.connect(full.path) as full_db:
+ truncated_features = history_features(
+ truncated_db,
+ "main.py",
+ "devscope@example.com",
+ {"main.py"},
+ as_of=as_of,
+ )
+ full_features = history_features(
+ full_db,
+ "main.py",
+ "devscope@example.com",
+ {"main.py"},
+ as_of=as_of,
+ )
+ assert full_features == truncated_features
+ assert cochange_partners(full_db, "main.py", as_of=as_of) == cochange_partners(
+ truncated_db, "main.py", as_of=as_of
+ )
+ assert recent_fix_count(full_db, "main.py", as_of=base + 500) == 1
+ assert recent_fix_count(full_db, "main.py", as_of=base + 501) == 2
+ assert recent_fix_count(full_db, "main.py", as_of=as_of) == 1
+
+
+def test_branch_commits_are_hidden_until_after_first_parent_landing(
+ tmp_path: Path, monkeypatch: Any
+) -> None:
+ repo = repository(tmp_path)
+ base = 1_780_100_000
+ (repo / "base.py").write_text("BASE = 1\n")
+ commit_at(repo, "base", base)
+ main_branch = git(repo, "branch", "--show-current")
+
+ git(repo, "switch", "-c", "feature")
+ (repo / "feature.py").write_text("FEATURE = 1\n")
+ feature_sha = commit_at(repo, "feature work", base + 100)
+
+ git(repo, "switch", main_branch)
+ (repo / "mainline.py").write_text("MAINLINE = 1\n")
+ mainline_sha = commit_at(repo, "mainline X", base + 200)
+ merge_sha = merge_at(repo, "feature", "merge feature", base + 300)
+
+ monkeypatch.setenv("DEVSCOPE_CACHE_DIR", str(tmp_path / "cache"))
+ result = RepositoryIndexer(repo, since="10 years ago", max_workers=1).build()
+ with sqlite3.connect(result.path) as database:
+ landings = dict(
+ database.execute(
+ "SELECT sha, landed_at FROM commits WHERE sha IN (?, ?, ?)",
+ (feature_sha, mainline_sha, merge_sha),
+ ).fetchall()
+ )
+ assert landings[mainline_sha] == base + 200
+ assert landings[merge_sha] == base + 300
+ assert landings[feature_sha] == base + 300
+
+ assert (
+ author_prior_commits(database, "feature.py", "devscope@example.com", as_of=base + 200)
+ == 0
+ )
+ assert (
+ author_prior_commits(database, "feature.py", "devscope@example.com", as_of=base + 300)
+ == 0
+ )
+ assert (
+ author_prior_commits(database, "feature.py", "devscope@example.com", as_of=base + 301)
+ == 1
+ )
+ assert (
+ author_prior_commits(database, "mainline.py", "devscope@example.com", as_of=base + 200)
+ == 0
+ )
+ assert (
+ author_prior_commits(database, "mainline.py", "devscope@example.com", as_of=base + 300)
+ == 1
+ )
+
+
+def test_git_reader_uses_mailmap_aware_author_identity(tmp_path: Path) -> None:
+ repo = repository(tmp_path)
+ (repo / ".mailmap").write_text(
+ "Canonical Author Alias Author \n"
+ )
+ commit_at(repo, "add mailmap", 1_780_200_000)
+ (repo / "main.py").write_text("VALUE = 1\n")
+ git(repo, "add", ".")
+ environment = os.environ.copy()
+ environment.update(
+ {
+ "GIT_AUTHOR_NAME": "Alias Author",
+ "GIT_AUTHOR_EMAIL": "alias@example.com",
+ "GIT_AUTHOR_DATE": "@1780200100 +0000",
+ "GIT_COMMITTER_DATE": "@1780200100 +0000",
+ }
+ )
+ subprocess.run(
+ ["git", "commit", "-m", "aliased author"],
+ cwd=repo,
+ env=environment,
+ text=True,
+ capture_output=True,
+ check=True,
+ )
+ sha = git(repo, "rev-parse", "HEAD")
+ reader = GitReader(repo)
+ single = reader.commit_info(sha)
+ batched = reader.commit_infos([sha])[sha]
+ assert (single.author_name, single.author_email) == (
+ "Canonical Author",
+ "canonical@example.com",
+ )
+ assert (batched.author_name, batched.author_email) == (
+ "Canonical Author",
+ "canonical@example.com",
+ )
diff --git a/tests/test_risk_v2.py b/tests/test_risk_v2.py
new file mode 100644
index 0000000..a9ef969
--- /dev/null
+++ b/tests/test_risk_v2.py
@@ -0,0 +1,283 @@
+"""Risk v2 evidence, provenance, graph and performance acceptance tests."""
+
+from __future__ import annotations
+
+import json
+import os
+import sqlite3
+import subprocess
+import time
+from dataclasses import replace
+from pathlib import Path
+from typing import Any, Optional
+
+import pytest
+
+from devscope.graph.imports import import_edges
+from devscope.index.incremental import RepositoryIndexer
+from devscope.index.store import IndexStore
+from devscope.reports import report_html, report_markdown
+from devscope.review import review_repository
+from devscope.risk.evidence import build_evidence, owners
+from devscope.risk.features import PRFeatures, importer_paths, pr_features
+from devscope.risk.model import RiskModel, RiskScore, score
+
+
+def git(
+ repo: Path,
+ *args: str,
+ env: Optional[dict[str, str]] = None, # noqa: UP045 - CI retains Python 3.9.
+) -> str:
+ completed = subprocess.run(
+ ["git", "-c", "commit.gpgsign=false", *args],
+ cwd=repo,
+ env=env,
+ text=True,
+ capture_output=True,
+ check=True,
+ )
+ return completed.stdout.strip()
+
+
+def commit_at(repo: Path, message: str, timestamp: int) -> str:
+ git(repo, "add", ".")
+ environment = os.environ.copy()
+ date = f"@{timestamp} +0000"
+ environment.update({"GIT_AUTHOR_DATE": date, "GIT_COMMITTER_DATE": date})
+ git(repo, "commit", "-m", message, env=environment)
+ return git(repo, "rev-parse", "HEAD")
+
+
+def scripted_repo(tmp_path: Path) -> Path:
+ repo = tmp_path / "repo"
+ repo.mkdir()
+ git(repo, "init", "-q", "-b", "main")
+ git(repo, "config", "user.name", "Alice Example")
+ git(repo, "config", "user.email", "alice@example.com")
+ base = 1_780_300_000
+ (repo / "billing").mkdir()
+ (repo / "billing/service.py").write_text("def charge():\n return 'wrong'\n")
+ (repo / "billing/models.py").write_text("PRICE = 1\n")
+ commit_at(repo, "introduce charge", base)
+ (repo / "billing/service.py").write_text("def charge():\n return 'right'\n")
+ commit_at(repo, "fix charge bug", base + 100)
+ for offset in (200, 300, 400):
+ (repo / "billing/service.py").write_text(
+ f"def charge():\n return 'right'\n\nCOUNT = {offset}\n"
+ )
+ (repo / "billing/models.py").write_text(f"PRICE = {offset}\n")
+ commit_at(repo, f"paired update {offset}", base + offset)
+ git(repo, "switch", "-q", "-c", "feature")
+ (repo / "billing/service.py").write_text(
+ "def charge():\n return 'right'\n\nCOUNT = 500\nEXTRA = True\n"
+ )
+ commit_at(
+ repo,
+ "expand billing\n\nCo-Authored-By: Claude ",
+ base + 500,
+ )
+ return repo
+
+
+def test_golden_evidence_json_on_scripted_repo(tmp_path: Path, monkeypatch: Any) -> None:
+ repo = scripted_repo(tmp_path)
+ monkeypatch.setenv("DEVSCOPE_CACHE_DIR", str(tmp_path / "cache"))
+ monkeypatch.setattr("devscope.review.graph_available", lambda: False)
+ report = review_repository(repo, "main")
+ actual = report["risk_files"]
+ expected = json.loads(
+ (Path(__file__).parent / "golden/risk_evidence_v2.json").read_text(encoding="utf-8")
+ )
+ assert actual == expected
+ defect = next(item for item in actual[0]["evidence"] if item["kind"] == "defect_history")
+ assert len(defect["refs"][0]) == 7
+ assert actual[0]["context"]["ai_authored_lines"] == 2
+ assert all(item["weight"] > 0 for item in actual[0]["evidence"])
+ assert all(item["weight"] < 0 for item in actual[0]["mitigating"])
+ markdown = report_markdown(report)
+ html = report_html(report)
+ assert "Mitigating factors" not in markdown
+ assert "PR changes +2/−1 lines" not in markdown
+ assert "Mitigating factors" in html
+ assert "PR changes +2/−1 lines" in html
+
+
+def test_500_file_features_are_under_two_seconds(tmp_path: Path) -> None:
+ with IndexStore(tmp_path / "index.sqlite") as store:
+ model = RiskModel()
+ started = time.perf_counter()
+ for number in range(500):
+ features = pr_features(
+ store.connection,
+ f"src/file_{number}.py",
+ "author@example.com",
+ {f"src/file_{number}.py"},
+ 10,
+ 2,
+ as_of=1_800_000_000,
+ graph_enabled=False,
+ )
+ model.score(features)
+ elapsed = time.perf_counter() - started
+ assert elapsed < 2.0, elapsed
+
+
+def test_importers_are_point_in_time_and_depth_two(tmp_path: Path) -> None:
+ with IndexStore(tmp_path / "index.sqlite") as store:
+ database = store.connection
+ for sha, path, landed in (("a", "core.py", 10), ("b", "api.py", 20), ("c", "web.py", 30)):
+ database.execute(
+ "INSERT INTO commits VALUES (?, 0, ?, ?, 'A', 'a@x', '', 0, 0, 1, 1, 0, '[]')",
+ (sha, landed, landed),
+ )
+ database.execute(
+ "INSERT INTO file_changes VALUES (?, ?, NULL, 1, 0, 1, 0)", (sha, path)
+ )
+ database.execute("INSERT INTO imports VALUES ('api.py', 'core.py', 'b', 20)")
+ database.execute("INSERT INTO imports VALUES ('web.py', 'api.py', 'c', 30)")
+ assert importer_paths(database, "core.py", as_of=30) == ["api.py"]
+ assert importer_paths(database, "core.py", as_of=31) == ["api.py", "web.py"]
+
+
+def test_owners_use_names_except_for_github_noreply_logins(tmp_path: Path) -> None:
+ with IndexStore(tmp_path / "index.sqlite") as store:
+ database = store.connection
+ identities = (
+ ("a", "Alice Smith", "alice@example.com"),
+ ("b", "Ignored", "123+octocat@users.noreply.github.com"),
+ ("c", "Ignored Too", "hubot@users.noreply.github.com"),
+ )
+ for number, (sha, name, email) in enumerate(identities, 1):
+ database.execute(
+ "INSERT INTO commits VALUES (?, 0, ?, ?, ?, ?, '', 0, 0, 1, 1, 0, '[]')",
+ (sha, number, number, name, email),
+ )
+ database.execute(
+ "INSERT INTO file_changes VALUES (?, 'app.py', NULL, 1, 0, 1, 0)", (sha,)
+ )
+ assert owners(database, "app.py", as_of=10) == [
+ "Alice Smith",
+ "@octocat",
+ "@hubot",
+ ]
+
+
+def test_defect_text_count_is_not_capped_with_refs(tmp_path: Path) -> None:
+ with IndexStore(tmp_path / "index.sqlite") as store:
+ database = store.connection
+ for number in range(12):
+ sha = f"{number:040x}"
+ database.execute(
+ "INSERT INTO commits VALUES (?, 0, ?, ?, 'A', 'a@x', '', 1, 0, 1, 1, 1, '[]')",
+ (sha, number + 1, number + 1),
+ )
+ database.execute(
+ "INSERT INTO bug_intro VALUES (?, ?, 'app.py', 'app.py', '[1]', 0, ?)",
+ (f"intro-{number}", sha, number + 1),
+ )
+ features = PRFeatures(1.0, 0, 0.0, 0, 0, 0.0, 0.0, None, None)
+ scored = RiskScore(0.8, 1.0, "global", {"defect_density": 1.0})
+ evidence = build_evidence(
+ database, "app.py", features, scored, {"app.py"}, as_of=100, rank=1
+ )["evidence"][0]
+ assert evidence["text"] == "12 bug fixes traced to this file in 12 months"
+ assert len(evidence["refs"]) == 10
+
+
+def test_zero_valued_non_events_are_not_evidence(tmp_path: Path) -> None:
+ with IndexStore(tmp_path / "index.sqlite") as store:
+ features = PRFeatures(0.0, 0, 0.0, 0, 0, 0.0, 0.0, 0, 0)
+ scored = RiskScore(
+ 0.8,
+ 1.0,
+ "global",
+ {
+ "defect_density": 1.0,
+ "recent_fix_count": 1.0,
+ "missing_cochange": -1.0,
+ "author_prior_commits": 0.5,
+ },
+ )
+ result = build_evidence(
+ store.connection, "app.py", features, scored, {"app.py"}, as_of=100, rank=1
+ )
+ assert result["evidence"] == [
+ {
+ "kind": "first_touch",
+ "weight": 0.5,
+ "text": "Author's first change to this file",
+ }
+ ]
+ assert result["mitigating"] == []
+
+
+def test_global_score_is_monotonic_in_raw_score(tmp_path: Path) -> None:
+ with IndexStore(tmp_path / "index.sqlite") as store:
+ assert not RiskModel().fitted
+ features = pr_features(
+ store.connection,
+ "app.py",
+ "author@example.com",
+ {"app.py"},
+ 5,
+ 1,
+ as_of=100,
+ graph_enabled=False,
+ )
+ lower = score(features)
+ higher = score(replace(features, lines_changed=features.lines_changed + 2.0))
+ assert lower.calibration == higher.calibration == "global"
+ assert lower.raw < higher.raw
+ assert lower.risk < higher.risk
+
+
+def test_import_graph_incremental_matches_cold_and_respects_as_of(
+ tmp_path: Path, monkeypatch: Any
+) -> None:
+ pytest.importorskip("tree_sitter_language_pack")
+ repo = tmp_path / "graph-repo"
+ repo.mkdir()
+ git(repo, "init", "-q", "-b", "main")
+ git(repo, "config", "user.name", "Graph Test")
+ git(repo, "config", "user.email", "graph@example.com")
+ (repo / "lib.py").write_text("VALUE = 1\n")
+ (repo / "app.py").write_text("from lib import VALUE\n")
+ commit_at(repo, "initial import", 1_780_400_000)
+
+ monkeypatch.setenv("DEVSCOPE_CACHE_DIR", str(tmp_path / "incremental-cache"))
+ first = RepositoryIndexer(repo, since="10 years ago", max_workers=1).build()
+ with sqlite3.connect(first.path) as database:
+ assert importer_paths(database, "lib.py", as_of=1_780_400_001) == ["app.py"]
+
+ (repo / "app.py").write_text("VALUE = 2\n")
+ commit_at(repo, "remove import", 1_780_400_100)
+ incremental = RepositoryIndexer(repo, since="10 years ago", max_workers=1).build()
+ with sqlite3.connect(incremental.path) as database:
+ incremental_rows = database.execute(
+ "SELECT path, imported_path, source_commit, landed_at FROM imports ORDER BY 1, 2, 3"
+ ).fetchall()
+ assert importer_paths(database, "lib.py", as_of=1_780_400_001) == ["app.py"]
+ assert importer_paths(database, "lib.py", as_of=1_780_400_101) == []
+
+ monkeypatch.setenv("DEVSCOPE_CACHE_DIR", str(tmp_path / "cold-cache"))
+ cold = RepositoryIndexer(repo, since="10 years ago", max_workers=1).build()
+ with sqlite3.connect(cold.path) as database:
+ cold_rows = database.execute(
+ "SELECT path, imported_path, source_commit, landed_at FROM imports ORDER BY 1, 2, 3"
+ ).fetchall()
+ assert incremental_rows == cold_rows
+
+
+@pytest.mark.parametrize(
+ ("path", "source", "target"),
+ [
+ ("app.py", "from lib import value\n", "lib.py"),
+ ("app.ts", "import {x} from './lib'\n", "lib.ts"),
+ ("app.go", 'import "example/project/lib"\n', "lib.go"),
+ ("app.swift", "import Lib\n", "Lib.swift"),
+ ("app.rs", "use crate::lib::value;\n", "lib.rs"),
+ ],
+)
+def test_tree_sitter_extracts_supported_imports(path: str, source: str, target: str) -> None:
+ pytest.importorskip("tree_sitter_language_pack")
+ assert target in import_edges(path, source, {path, target})
diff --git a/uv.lock b/uv.lock
index 38e037c..0559ddf 100644
--- a/uv.lock
+++ b/uv.lock
@@ -2,7 +2,8 @@ version = 1
revision = 3
requires-python = ">=3.9"
resolution-markers = [
- "python_full_version >= '3.10'",
+ "python_full_version >= '3.11'",
+ "python_full_version == '3.10.*'",
"python_full_version < '3.10'",
]
@@ -26,7 +27,8 @@ name = "click"
version = "8.3.1"
source = { registry = "https://pypi.org/simple" }
resolution-markers = [
- "python_full_version >= '3.10'",
+ "python_full_version >= '3.11'",
+ "python_full_version == '3.10.*'",
]
dependencies = [
{ name = "colorama", marker = "sys_platform == 'win32'" },
@@ -169,7 +171,8 @@ name = "coverage"
version = "7.13.4"
source = { registry = "https://pypi.org/simple" }
resolution-markers = [
- "python_full_version >= '3.10'",
+ "python_full_version >= '3.11'",
+ "python_full_version == '3.10.*'",
]
sdist = { url = "https://files.pythonhosted.org/packages/24/56/95b7e30fa389756cb56630faa728da46a27b8c6eb46f9d557c68fff12b65/coverage-7.13.4.tar.gz", hash = "sha256:e5c8f6ed1e61a8b2dcdf31eb0b9bbf0130750ca79c1c49eb898e2ad86f5ccc91", size = 827239, upload-time = "2026-02-09T12:59:03.86Z" }
wheels = [
@@ -308,6 +311,10 @@ dev = [
{ name = "pytest-cov" },
{ name = "ruff" },
]
+graph = [
+ { name = "tree-sitter-language-pack", version = "1.23.1", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version == '3.10.*'" },
+ { name = "tree-sitter-language-pack", version = "1.29.0", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version >= '3.11'" },
+]
[package.metadata]
requires-dist = [
@@ -321,8 +328,9 @@ requires-dist = [
{ name = "rich", specifier = ">=13.0.0" },
{ name = "ruff", marker = "extra == 'dev'", specifier = ">=0.1.0" },
{ name = "tomli", marker = "python_full_version < '3.11'", specifier = ">=2.0" },
+ { name = "tree-sitter-language-pack", marker = "python_full_version >= '3.10' and extra == 'graph'", specifier = ">=0.9.0" },
]
-provides-extras = ["dev"]
+provides-extras = ["graph", "dev"]
[[package]]
name = "exceptiongroup"
@@ -378,7 +386,8 @@ name = "iniconfig"
version = "2.3.0"
source = { registry = "https://pypi.org/simple" }
resolution-markers = [
- "python_full_version >= '3.10'",
+ "python_full_version >= '3.11'",
+ "python_full_version == '3.10.*'",
]
sdist = { url = "https://files.pythonhosted.org/packages/72/34/14ca021ce8e5dfedc35312d08ba8bf51fdd999c576889fc2c24cb97f4f10/iniconfig-2.3.0.tar.gz", hash = "sha256:c76315c77db068650d49c5b56314774a7804df16fee4402c1f19d6d15d8c4730", size = 20503, upload-time = "2025-10-18T21:55:43.219Z" }
wheels = [
@@ -502,7 +511,8 @@ name = "markdown-it-py"
version = "4.0.0"
source = { registry = "https://pypi.org/simple" }
resolution-markers = [
- "python_full_version >= '3.10'",
+ "python_full_version >= '3.11'",
+ "python_full_version == '3.10.*'",
]
dependencies = [
{ name = "mdurl" },
@@ -617,7 +627,8 @@ name = "platformdirs"
version = "4.7.0"
source = { registry = "https://pypi.org/simple" }
resolution-markers = [
- "python_full_version >= '3.10'",
+ "python_full_version >= '3.11'",
+ "python_full_version == '3.10.*'",
]
sdist = { url = "https://files.pythonhosted.org/packages/71/25/ccd8e88fcd16a4eb6343a8b4b9635e6f3928a7ebcd82822a14d20e3ca29f/platformdirs-4.7.0.tar.gz", hash = "sha256:fd1a5f8599c85d49b9ac7d6e450bc2f1aaf4a23f1fe86d09952fe20ad365cf36", size = 23118, upload-time = "2026-02-12T22:21:53.764Z" }
wheels = [
@@ -668,7 +679,8 @@ name = "pytest"
version = "9.0.2"
source = { registry = "https://pypi.org/simple" }
resolution-markers = [
- "python_full_version >= '3.10'",
+ "python_full_version >= '3.11'",
+ "python_full_version == '3.10.*'",
]
dependencies = [
{ name = "colorama", marker = "sys_platform == 'win32'" },
@@ -802,6 +814,148 @@ wheels = [
{ url = "https://files.pythonhosted.org/packages/23/d1/136eb2cb77520a31e1f64cbae9d33ec6df0d78bdf4160398e86eec8a8754/tomli-2.4.0-py3-none-any.whl", hash = "sha256:1f776e7d669ebceb01dee46484485f43a4048746235e683bcdffacdf1fb4785a", size = 14477, upload-time = "2026-01-11T11:22:37.446Z" },
]
+[[package]]
+name = "tree-sitter"
+version = "0.26.1"
+source = { registry = "https://pypi.org/simple" }
+resolution-markers = [
+ "python_full_version == '3.10.*'",
+]
+sdist = { url = "https://files.pythonhosted.org/packages/e6/ca/3d69b21b2328dadee34a6cae65bc84e2b4e0c72bfb9147b7a2d4ba8110a0/tree_sitter-0.26.1.tar.gz", hash = "sha256:9919cbaf02d17fa9a4cd0e6da496aecf901b758e6eacf122eee393e3ef08aacd", size = 194642, upload-time = "2026-11-09T15:18:09.448Z" }
+wheels = [
+ { url = "https://files.pythonhosted.org/packages/5d/c7/29dcbbfade858b69cf953efe2fe573b3dda4a2971acec44ddc3b260054a0/tree_sitter-0.26.1-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:8c71f8fa3c76e26bcffb11ffbb3c8af9633d5052b8cc3bfdc739ef0b32b990c7", size = 150322, upload-time = "2026-11-09T15:17:17.299Z" },
+ { url = "https://files.pythonhosted.org/packages/7d/98/6891c912773af054fb2ee30326599bd886befe3aedc70e0a1d9288bec18d/tree_sitter-0.26.1-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:03e1fbf51cd0361409478e7ca97f58798d3206f34f1ee8b4de7f21d52e957559", size = 142092, upload-time = "2026-11-09T15:17:18.58Z" },
+ { url = "https://files.pythonhosted.org/packages/c0/0a/ba1ab112fd4f75e11771b20fcc0d305b0629fe7d95ee9b818bd9ac5e763f/tree_sitter-0.26.1-cp310-cp310-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:b8ffc0cb6b7226b9b3121daca6d54510505431f4a8b370bbb79fa2d7963a6b85", size = 640186, upload-time = "2026-11-09T15:17:19.782Z" },
+ { url = "https://files.pythonhosted.org/packages/8c/77/8277ac4c072d565b3fef889c840386123474ce2cb9e77de459385544ac29/tree_sitter-0.26.1-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:6dc56eb5260d5f4da19ba16c8aeac3d6829237ef0aaf7dda134d778d42969769", size = 668826, upload-time = "2026-11-09T15:17:21.043Z" },
+ { url = "https://files.pythonhosted.org/packages/55/cd/756bbc151f729f547e629b897356a272d68dd1daa9026d4530b455743a61/tree_sitter-0.26.1-cp310-cp310-manylinux_2_31_riscv64.manylinux_2_39_riscv64.whl", hash = "sha256:79a7fdfa88d322db1ff417defd11e01b6f4feba8401022335ec393da4e57ebed", size = 651734, upload-time = "2026-11-09T15:17:23.026Z" },
+ { url = "https://files.pythonhosted.org/packages/ca/7f/cc067e8fa72d8d49da5690ce99bf6c3ff479d32d052dca5d1c495be90695/tree_sitter-0.26.1-cp310-cp310-musllinux_1_2_x86_64.whl", hash = "sha256:256094fab3ac3c2cffcda1ff3fd0b0b786a4f62b895d59d894ef25578e0d797c", size = 665709, upload-time = "2026-11-09T15:17:24.331Z" },
+ { url = "https://files.pythonhosted.org/packages/fb/34/1b5e252c1337eb631172a0cc262199a360b6506662f2daa657f2c3d8330f/tree_sitter-0.26.1-cp310-cp310-win_amd64.whl", hash = "sha256:e7c172e028e44e67fa79a6a973d2f01fa6589fb6c3262804f4d590998d2051b7", size = 130633, upload-time = "2026-11-09T15:17:25.412Z" },
+ { url = "https://files.pythonhosted.org/packages/33/12/45674112046335c2631dcb908209b5a91fa8bedb9544add8e5a169e61904/tree_sitter-0.26.1-cp310-cp310-win_arm64.whl", hash = "sha256:a53679ae26f2bebe540084825e60de48b4b66577efcfcf374114fc4c67038e23", size = 120680, upload-time = "2026-11-09T15:17:26.692Z" },
+ { url = "https://files.pythonhosted.org/packages/83/a9/7d55957f5beec32bd041ed1076d2096e59396555c42843da37d89720ceea/tree_sitter-0.26.1-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:f1ec14b8eb354c9afb9de1a9cf16c6ffb770aa31962509d062ae513735a90c63", size = 150328, upload-time = "2026-11-09T15:17:27.96Z" },
+ { url = "https://files.pythonhosted.org/packages/52/68/3a267561dc7552b073b39eec74df0e2bfffd5da078855c6e3f84ce99fc14/tree_sitter-0.26.1-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:c3c207bb7cd28aaa804f7062b680fa5dbceb2135c55018c62c43fbda3dac6d0f", size = 142096, upload-time = "2026-11-09T15:17:29.081Z" },
+ { url = "https://files.pythonhosted.org/packages/8a/31/374923548e16509763ce774dfe969a5988e8bd69a2536c92dd1dabf64a9c/tree_sitter-0.26.1-cp311-cp311-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:0a7a9ee719645d656fe252afbb437b4bb5e9a535e5287fc04c0831876b2de07a", size = 645270, upload-time = "2026-11-09T15:17:30.469Z" },
+ { url = "https://files.pythonhosted.org/packages/3d/06/fabf2bd1a4159ae54fc6dc55fe532d88426e34824a0eda2d24542e9839cd/tree_sitter-0.26.1-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:1529457e099ee5963b9738d42ed8133316d936157e912aa4a985f4fdaf018ada", size = 674059, upload-time = "2026-11-09T15:17:32.363Z" },
+ { url = "https://files.pythonhosted.org/packages/9d/6c/f466186b3c844c22095a7eca00307ae14166d3f1c4cc2bf4b03a7253a3c2/tree_sitter-0.26.1-cp311-cp311-manylinux_2_31_riscv64.manylinux_2_39_riscv64.whl", hash = "sha256:9b3b6ea0867ad88b04323260dfd1c746315e6e45ec1a4884ac7d9182a32b3e11", size = 657129, upload-time = "2026-11-09T15:17:33.523Z" },
+ { url = "https://files.pythonhosted.org/packages/a3/06/9a3bf38815add3ca23079ca43b178f6a114eb6ae61cbea4de9db3aacfb4a/tree_sitter-0.26.1-cp311-cp311-musllinux_1_2_x86_64.whl", hash = "sha256:ae770e688436c80991ef21410c66f20d307a5d6daec58f9eadd384e94d77ce14", size = 671598, upload-time = "2026-11-09T15:17:34.839Z" },
+ { url = "https://files.pythonhosted.org/packages/7d/ff/52b6fbdcef205d238ad12ead21f48a2a443b15ee93cbeeaa428882598262/tree_sitter-0.26.1-cp311-cp311-win_amd64.whl", hash = "sha256:10ffee79cfddbb16231d6f5152f895240d425e359ea9785dc2fa043cabf7281c", size = 130635, upload-time = "2026-11-09T15:17:36.105Z" },
+ { url = "https://files.pythonhosted.org/packages/78/89/574ce07e57307f7ef7d7a67bea2777ecf0f4c3daa7b037119513d64816ac/tree_sitter-0.26.1-cp311-cp311-win_arm64.whl", hash = "sha256:bcfc3d54a486946a17f58139630fdd49c61d9c9b4a790e2a9f35579679c92307", size = 120679, upload-time = "2026-11-09T15:17:37.112Z" },
+ { url = "https://files.pythonhosted.org/packages/65/7d/67970014769483318f7ea91cae46a8dd68168c69f7407f4eb61b0213891a/tree_sitter-0.26.1-cp312-cp312-macosx_10_13_x86_64.whl", hash = "sha256:c413bfec1dbee3fc17b967537d26da1429c07a593da251a71843f5e34c8ea0ff", size = 150472, upload-time = "2026-11-09T15:17:38.382Z" },
+ { url = "https://files.pythonhosted.org/packages/a6/cd/da10e28e5305b5900d1bc503ac78214efca97fa5bc09b86cf466125a1bde/tree_sitter-0.26.1-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:8ac2d0d115e73be14dbd569b353a4f762368c134a64248aa4483afdc297dd4b4", size = 142047, upload-time = "2026-11-09T15:17:39.467Z" },
+ { url = "https://files.pythonhosted.org/packages/e7/b2/9dc423a8cb2e57e2ee982bcfd44fe44e37d7ae2a7ba8e03d93bc6a7b8fb2/tree_sitter-0.26.1-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:8ecef3db771e6f50a7010310056a54bca11279e0f10597fff78c215a879de965", size = 647888, upload-time = "2026-11-09T15:17:40.96Z" },
+ { url = "https://files.pythonhosted.org/packages/9a/d9/238f956bff9be77ad43b7efe5b03fdc0c5ccef41b1018888c420d7eb604b/tree_sitter-0.26.1-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:7b14ac81a2afdcf75610f714f1d2eeaac40da93965c104cabb5c4c2b536a488a", size = 678547, upload-time = "2026-11-09T15:17:42.536Z" },
+ { url = "https://files.pythonhosted.org/packages/94/47/3e02e6cd037fc83a4cad9c031a7af6195a5040ec226bd6f1da872fab8754/tree_sitter-0.26.1-cp312-cp312-manylinux_2_31_riscv64.manylinux_2_39_riscv64.whl", hash = "sha256:0d95e054892e378fe3dbd75d709ecc05c97609eec916ccc30eb301b5c21a6f86", size = 659146, upload-time = "2026-11-09T15:17:44.172Z" },
+ { url = "https://files.pythonhosted.org/packages/39/33/e6e4c2c9dc4ab88f6a7e1ca4f3b8a263ba273ea1ca83f643d191ab6e1289/tree_sitter-0.26.1-cp312-cp312-musllinux_1_2_x86_64.whl", hash = "sha256:90c03a777889b8f767b8d4b5d700fbfe2db6cdc05f8ee7fb8d33ab2ef1097972", size = 675175, upload-time = "2026-11-09T15:17:45.493Z" },
+ { url = "https://files.pythonhosted.org/packages/f8/b3/ae76ad04f059594603f58003da40b9c4238d960823a8a05aba2ecb057976/tree_sitter-0.26.1-cp312-cp312-win_amd64.whl", hash = "sha256:df8663ce8106bd49d379697cc4471c92537e0c25a8c63bf1246958fdfe22a979", size = 130915, upload-time = "2026-11-09T15:17:46.707Z" },
+ { url = "https://files.pythonhosted.org/packages/61/57/7b7625a80da743562673d69e0b26cc281380ce95b78f34369b5d6eeb016f/tree_sitter-0.26.1-cp312-cp312-win_arm64.whl", hash = "sha256:5d28096eef96c2111b2244394a3340e0d3d7ac8f124eb9806eb8f783cd87c30c", size = 120726, upload-time = "2026-11-09T15:17:47.728Z" },
+ { url = "https://files.pythonhosted.org/packages/3c/f5/f5b7e8deeccb5e10987775c3e7bd1f98030459329a6d570d0eb580ed52f5/tree_sitter-0.26.1-cp313-cp313-macosx_10_13_x86_64.whl", hash = "sha256:904bcb36111fa74241d920c5785ee206b8f9fe41b6d5348daa52d563faafba6b", size = 150473, upload-time = "2026-11-09T15:17:48.829Z" },
+ { url = "https://files.pythonhosted.org/packages/41/88/e25eb561b8bb902bac508baf1e2be624fbcc7c6c5f84fdf9a09bc07e7197/tree_sitter-0.26.1-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:16ada9e60b91cbaba7715c649655351cdf97ddc2f07fb11388924e027abf53e7", size = 142067, upload-time = "2026-11-09T15:17:49.948Z" },
+ { url = "https://files.pythonhosted.org/packages/07/30/379b9ccdac8d658cca2aac6416cc6f01f5dec49ff919b485f394500719a6/tree_sitter-0.26.1-cp313-cp313-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:92aaec1a5d4318b7e563075365336d89dcfb613f716a4491bfd9a012a133aa74", size = 648685, upload-time = "2026-11-09T15:17:51.03Z" },
+ { url = "https://files.pythonhosted.org/packages/52/1c/e48d13bc08a7130d33df55a58762b5b6b8974407e9c254d0253feb2b300f/tree_sitter-0.26.1-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:00e55f823de46b2bbcab9ca58a4c2a7ccc2b1dc28ed3fad7355fb32726008e21", size = 679201, upload-time = "2026-11-09T15:17:52.392Z" },
+ { url = "https://files.pythonhosted.org/packages/fe/f5/06ff88ed355becea5e0900dd0289d33fc02a37f4af482025c255f64d6bc3/tree_sitter-0.26.1-cp313-cp313-manylinux_2_31_riscv64.manylinux_2_39_riscv64.whl", hash = "sha256:57fa04154e292972b8970a9728515bdf0addedafb10452156e0667381c77805e", size = 659819, upload-time = "2026-11-09T15:17:54.028Z" },
+ { url = "https://files.pythonhosted.org/packages/82/3b/2652e78b52d72f061a50e82af446df7c1497fbb7a8afbbd3cab8a0d9936c/tree_sitter-0.26.1-cp313-cp313-musllinux_1_2_x86_64.whl", hash = "sha256:59ee219cdd35bbcfe9ed2cc8faba16ab4d88b19574f7ac15074d89de5c0c273c", size = 675285, upload-time = "2026-11-09T15:17:55.429Z" },
+ { url = "https://files.pythonhosted.org/packages/e9/cd/77c0cc542e76e96da58b01f27ec454aadd6300fcff96abbb31b77f7515fc/tree_sitter-0.26.1-cp313-cp313-win_amd64.whl", hash = "sha256:0f8ca207d7f6e50b9a883bafa5fd3474758387156050057f269f56cd1b240bb2", size = 130907, upload-time = "2026-11-09T15:17:57.073Z" },
+ { url = "https://files.pythonhosted.org/packages/c0/5c/80da017e9c4f4b01eb0d153ed7f3341c355d4455000b95d390dc70d756f8/tree_sitter-0.26.1-cp313-cp313-win_arm64.whl", hash = "sha256:8f69e35087b72cd3f370400c173d0a45e16cee426f283b116d5eb6a936bd0600", size = 120723, upload-time = "2026-11-09T15:17:58.103Z" },
+ { url = "https://files.pythonhosted.org/packages/ba/47/8bb05ae418983720aafc5367ff3253e608b2b18f56462a20b923a014dc7a/tree_sitter-0.26.1-cp314-cp314-macosx_10_15_x86_64.whl", hash = "sha256:c66af3fb35e2380248a2c5a000d735528c116f65b028d1e4f8d44b378d006fcf", size = 150510, upload-time = "2026-11-09T15:17:59.422Z" },
+ { url = "https://files.pythonhosted.org/packages/c7/62/79fe26c919e8d081094df31bef84eb8a75c64768bc505c36eda72d382edb/tree_sitter-0.26.1-cp314-cp314-macosx_11_0_arm64.whl", hash = "sha256:c46becdb79b49d68f1084e335eddc74318b25f2d4fcd33de46fe259fd031ba1c", size = 142148, upload-time = "2026-11-09T15:18:00.489Z" },
+ { url = "https://files.pythonhosted.org/packages/05/97/858b27d159c69cc14a1ae86c77633f25bddb4c80be8505dba8367c4741ca/tree_sitter-0.26.1-cp314-cp314-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:02d73ec124fa74e64558f5fdb3ae58d8af19d5e8b4a70197b45ebf22c83e822f", size = 650625, upload-time = "2026-11-09T15:18:01.937Z" },
+ { url = "https://files.pythonhosted.org/packages/29/e4/035caa6a831379b378f4a9e44c44348bd33bbd9a7d8b2d64549bc891e610/tree_sitter-0.26.1-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:0c1b48e17b26cf555060c1285b35f49eeb345222e62c2a35d70c393a7c61c65b", size = 680138, upload-time = "2026-11-09T15:18:03.867Z" },
+ { url = "https://files.pythonhosted.org/packages/fe/ed/5462539303dbe7d5c4a653fa2cc5aeac3692f9b83a2b53875dba935fdd64/tree_sitter-0.26.1-cp314-cp314-manylinux_2_31_riscv64.manylinux_2_39_riscv64.whl", hash = "sha256:82f82e39d0da2f552d5ddbbf8d6fcd71571ec4b09814196ac5bf8233a13e751f", size = 660875, upload-time = "2026-11-09T15:18:05.208Z" },
+ { url = "https://files.pythonhosted.org/packages/80/64/ce86bba1987ba13b8337afdef34a189912fe1d29dd60ccfda0443fb20214/tree_sitter-0.26.1-cp314-cp314-musllinux_1_2_x86_64.whl", hash = "sha256:25ebcf9ab2f5e4687a2ee9943e3ddfa7df67eb180058825887e461ba4750a336", size = 675316, upload-time = "2026-11-09T15:18:06.309Z" },
+ { url = "https://files.pythonhosted.org/packages/e9/da/2bc600b0e1aa6c6160abea62dfae4da8b7d934d45cb550e25553519c0d72/tree_sitter-0.26.1-cp314-cp314-win_amd64.whl", hash = "sha256:b1e079af889beed37ae2f8aa24078018ed63ff3bb566f47212a4f90d7990528e", size = 133677, upload-time = "2026-11-09T15:18:07.338Z" },
+ { url = "https://files.pythonhosted.org/packages/9f/75/c3db59cd8a8dd5fbb382b21a19c71665ba67739a8b36eca4712c921f892d/tree_sitter-0.26.1-cp314-cp314-win_arm64.whl", hash = "sha256:5c24824174a374916365cab0469243fa5220d51fd6b168a145cbb61afba8e9f5", size = 124621, upload-time = "2026-11-09T15:18:08.413Z" },
+]
+
+[[package]]
+name = "tree-sitter"
+version = "0.27.0"
+source = { registry = "https://pypi.org/simple" }
+resolution-markers = [
+ "python_full_version >= '3.11'",
+]
+sdist = { url = "https://files.pythonhosted.org/packages/6f/ed/07c594be37b6fd8d4b43b1deb7acc03008a613bf0fa6e3e8576ebb5639fe/tree_sitter-0.27.0.tar.gz", hash = "sha256:5ac47f29033af9c01b034f79f0234cde40d73a36976bce05256b3dbf05a2db4b", size = 234895, upload-time = "2026-11-23T09:41:51.824Z" }
+wheels = [
+ { url = "https://files.pythonhosted.org/packages/89/cf/d4b66ef0b7cfa5737390f7d3a19c85f33fb50b07f67f8110385518a36225/tree_sitter-0.27.0-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:96d305ec1e47aa6b4ed5c8aa39718c1b70eca08ba67a495d6c525e57b1ce3476", size = 156920, upload-time = "2026-11-23T09:41:13.495Z" },
+ { url = "https://files.pythonhosted.org/packages/8f/0a/962574186cf06dfc6b50b440927e9e4e66b485335765fcf083a97e28c7cb/tree_sitter-0.27.0-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:ace1eb2d1235827d4478faefac81ad42f9802ae7182921d45d6c04e4ea4f604d", size = 147567, upload-time = "2026-11-23T09:41:14.665Z" },
+ { url = "https://files.pythonhosted.org/packages/9b/57/d10932b30638e17501e617ff49ed02b6773e32bf124de2e4ab19cd36dac9/tree_sitter-0.27.0-cp311-cp311-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:5598266ca6f6d0f22c7ba312cc9b0bac988e6f1117a4fb54cb6ae9e228ec92d5", size = 671928, upload-time = "2026-11-23T09:41:15.52Z" },
+ { url = "https://files.pythonhosted.org/packages/55/12/96c6f72fe360092227f4f3a3b3b6d6997618cdf5bffc849f37a2763fdd78/tree_sitter-0.27.0-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:5fd60905d44b4aeb4c8e60ebdc60afba0eb5023cfc826b8c0a60ddc40e75225f", size = 701771, upload-time = "2026-11-23T09:41:16.488Z" },
+ { url = "https://files.pythonhosted.org/packages/05/eb/903d1d766aeb76bb4e63ae7034b36d0c59d4dc174f7288e2513c53e389b7/tree_sitter-0.27.0-cp311-cp311-manylinux_2_31_riscv64.manylinux_2_39_riscv64.whl", hash = "sha256:286b36507245068d627b8ee3023c4ca86f1d1f86ed3bc124b9cca746afc2c0a2", size = 683390, upload-time = "2026-11-23T09:41:17.674Z" },
+ { url = "https://files.pythonhosted.org/packages/7b/f3/da6aad335a1bafe2570ace91a9bc40f8b1ac6f79867cae675abab748dcb7/tree_sitter-0.27.0-cp311-cp311-musllinux_1_2_x86_64.whl", hash = "sha256:4f78f7108e12952b80f520ee9fe16163ef45b0ff262245a9726a1bc489ba7f7a", size = 699098, upload-time = "2026-11-23T09:41:18.638Z" },
+ { url = "https://files.pythonhosted.org/packages/ef/04/0be1ffc3a78b58cbfbcd617b060f8083b46c759d405ace8d44a92bf0bf20/tree_sitter-0.27.0-cp311-cp311-win_amd64.whl", hash = "sha256:577e875955eb2561c43c17f9bf22387e152493d3481adb75d7e23887151ee768", size = 135515, upload-time = "2026-11-23T09:41:19.579Z" },
+ { url = "https://files.pythonhosted.org/packages/1f/ee/71bcf89dbe6db12e1534a3b390005ea2116023d990785df7ff2ba21ab948/tree_sitter-0.27.0-cp311-cp311-win_arm64.whl", hash = "sha256:d51e4b20262296971262bb220f4b98b754b4d034383fe6caac7254f7adf80a82", size = 125773, upload-time = "2026-11-23T09:41:20.364Z" },
+ { url = "https://files.pythonhosted.org/packages/9f/eb/1671229ef331ae30f1b331f64c1545b2ddc9d5f0af43364674309b2d8c59/tree_sitter-0.27.0-cp312-cp312-macosx_10_13_x86_64.whl", hash = "sha256:32a18851d9ddb29bbebae3d41c3ec91e20d24a9f20c28859982e2a1299f2392c", size = 157150, upload-time = "2026-11-23T09:41:21.422Z" },
+ { url = "https://files.pythonhosted.org/packages/a7/ef/9563fc6ecc545db58874e3657dbb9c9f7a259c41b5c6978e4bf8a59e4119/tree_sitter-0.27.0-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:c55ffe41a33e4dfa1995f66489aab2e21112e16db3ebc2140f1efbbb26193c26", size = 147602, upload-time = "2026-11-23T09:41:22.202Z" },
+ { url = "https://files.pythonhosted.org/packages/f8/e4/c9917e249d6f96b6fca16a86582a69d8d5ceebfc5e5ad60df07a061ab8e6/tree_sitter-0.27.0-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:61a7637786ca2efead67e9861746a2876b3e5ef5fa2542ed278f4dbe5976bfa7", size = 676069, upload-time = "2026-11-23T09:41:23.015Z" },
+ { url = "https://files.pythonhosted.org/packages/8c/6a/e33514c6388759743f592dd99b898dfd3d531d56efe4ddf64b9be1905f04/tree_sitter-0.27.0-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:646e716cc256497e76a86b7651e2aa32c01c15b8e2ff703fa19d2fb952f0a368", size = 707246, upload-time = "2026-11-23T09:41:23.95Z" },
+ { url = "https://files.pythonhosted.org/packages/77/9e/140efda7ce51d21dba2776ed92effe4fed545e7bc60d325d89c6e1eeb2f7/tree_sitter-0.27.0-cp312-cp312-manylinux_2_31_riscv64.manylinux_2_39_riscv64.whl", hash = "sha256:e48bab49c2898ee36c118e152b0956ce29f5934bc35c99c598fc32e67db6c33d", size = 685663, upload-time = "2026-11-23T09:41:25.16Z" },
+ { url = "https://files.pythonhosted.org/packages/cf/23/7f8dd9f838417a756c4aa3841d4d498ef57e36de83118ad1564e227fbae8/tree_sitter-0.27.0-cp312-cp312-musllinux_1_2_x86_64.whl", hash = "sha256:fb258a8ab8d662744efff100c11fe31ee17358636b2ee020cc46246aa90d553e", size = 701189, upload-time = "2026-11-23T09:41:26.233Z" },
+ { url = "https://files.pythonhosted.org/packages/40/df/082c4dbcc866da9e748409cfdf653876b2dcd8627fdb7dc3b6789b664713/tree_sitter-0.27.0-cp312-cp312-win_amd64.whl", hash = "sha256:b595666aae161f21307b5c6475aff305f073fee7413cb51bf2e0a06b2e686d71", size = 135823, upload-time = "2026-11-23T09:41:27.551Z" },
+ { url = "https://files.pythonhosted.org/packages/ec/8c/523ddd3b18100a97733b206277162ff8a1f34897a0a13e1671afaf45c9c4/tree_sitter-0.27.0-cp312-cp312-win_arm64.whl", hash = "sha256:0c46a7d74a497abf2e3dba9c7b79f7fc1ebe4351e0b0bbb7200a5c61625e60dd", size = 125343, upload-time = "2026-11-23T09:41:28.369Z" },
+ { url = "https://files.pythonhosted.org/packages/7d/b3/a05997ddaa7dd9fb15c0fa5b0b50230f20d7364a35f55fbd0606f13a01e8/tree_sitter-0.27.0-cp313-cp313-macosx_10_13_x86_64.whl", hash = "sha256:6cd5901c3982e6fc5375b1b05c864dcd83ab7d0e2f3bac6732479d2d35f3d35f", size = 157121, upload-time = "2026-11-23T09:41:29.16Z" },
+ { url = "https://files.pythonhosted.org/packages/04/58/3b1cb94da9966e8e22af72fc1f051ead41eda57a7ba78791e82d0bacb99f/tree_sitter-0.27.0-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:c0c37c91339c61f5fc19443f879e4ac7b627a4f1160f2bb0df5a2e068c8fe296", size = 147595, upload-time = "2026-11-23T09:41:30.017Z" },
+ { url = "https://files.pythonhosted.org/packages/a0/65/fe1151bcda4a9a039a4ea5dab1440b15bda6ca08f94f5d3721c99db207d8/tree_sitter-0.27.0-cp313-cp313-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:0c42d86494bc3832047d66424fde027285f922002be3fddea41091f3f4d6e356", size = 676606, upload-time = "2026-11-23T09:41:30.82Z" },
+ { url = "https://files.pythonhosted.org/packages/a9/4a/ba67ab83d25ce096debaf43aa8d55aba13985f5354cdecc39c8c793b3b65/tree_sitter-0.27.0-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:94403572638a71500da80b3d001b17f36c503c158ead38f118bbc7994cd3baa9", size = 707930, upload-time = "2026-11-23T09:41:31.811Z" },
+ { url = "https://files.pythonhosted.org/packages/b6/91/5499488a68bcecb76e718aefe4ab3d124b2e4e5d30fab5a6e3d7b0719670/tree_sitter-0.27.0-cp313-cp313-manylinux_2_31_riscv64.manylinux_2_39_riscv64.whl", hash = "sha256:09f8f1f9350a710f13db0580fcac1bb3ae263aabf4cf7c1ed39f476b853c8ee8", size = 685943, upload-time = "2026-11-23T09:41:32.758Z" },
+ { url = "https://files.pythonhosted.org/packages/50/4b/6efddee4d015b1b984eab1eefb826724037ae7f83e0ea19e40170d33d05f/tree_sitter-0.27.0-cp313-cp313-musllinux_1_2_x86_64.whl", hash = "sha256:ccedbb12542260634f26eccb47f38bf211ef183d9afbc06665f0ecf81aa44a10", size = 701160, upload-time = "2026-11-23T09:41:34.022Z" },
+ { url = "https://files.pythonhosted.org/packages/02/49/95a9329959ac39215443272a67f36a70d2f4f01df8eb10f8803dc47eb1ed/tree_sitter-0.27.0-cp313-cp313-win_amd64.whl", hash = "sha256:0f0f07dadd989cfc18f58443385f34f14cf71e68921aece953d6c359ddad028e", size = 135817, upload-time = "2026-11-23T09:41:35.091Z" },
+ { url = "https://files.pythonhosted.org/packages/63/7c/e5a984dccd40c57c3ed5604abc9a3507b791d8a29995d6586b7389a73f1c/tree_sitter-0.27.0-cp313-cp313-win_arm64.whl", hash = "sha256:64ef3c1d79b2d958d0aa6dd0b69be23702b5bcafff305e2db15b9cdc9cb63a30", size = 125355, upload-time = "2026-11-23T09:41:35.854Z" },
+ { url = "https://files.pythonhosted.org/packages/e4/54/ca4b337b003d570c68b9c9ff6e8c1dd6229ee8b18500cd184a5ad5aae551/tree_sitter-0.27.0-cp314-cp314-macosx_10_15_x86_64.whl", hash = "sha256:b838aeabce128e395e524c18d7f9d9a8333b1c677abb58c36720f2492b22bd0b", size = 157193, upload-time = "2026-11-23T09:41:36.62Z" },
+ { url = "https://files.pythonhosted.org/packages/63/62/ca5cfde096d97be443e96d5f5e3040a21e7cd66c32ef186292517192a562/tree_sitter-0.27.0-cp314-cp314-macosx_11_0_arm64.whl", hash = "sha256:c1a2113437feee15352bfc5cbb0758fa0aeaae20c75e4f281655a885d0a061f1", size = 147634, upload-time = "2026-11-23T09:41:37.674Z" },
+ { url = "https://files.pythonhosted.org/packages/20/d7/f1e6de6b380359cb7b001ca8b2d2196e69f3c1e75fc1e8f063b0703cce80/tree_sitter-0.27.0-cp314-cp314-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:bce447eeaa568cde3ccc58e84b5913487a4c6a62da26e3dde29db0c09bbb7002", size = 677704, upload-time = "2026-11-23T09:41:38.53Z" },
+ { url = "https://files.pythonhosted.org/packages/e5/3f/1284fd331f72d4fd6683dc57b26c9bf55297ac8e4570b5c5670ce95473f2/tree_sitter-0.27.0-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:691f917b6e8d4273cfb7756bdf96ced872bca99cfd0b93563c13177effe1ddc6", size = 708308, upload-time = "2026-11-23T09:41:39.931Z" },
+ { url = "https://files.pythonhosted.org/packages/a5/cc/3dcbcaf2639aadb7a0af4754efc06f1666362e7044dd46b928c7452b7afc/tree_sitter-0.27.0-cp314-cp314-manylinux_2_31_riscv64.manylinux_2_39_riscv64.whl", hash = "sha256:4d2e35d8be219b509caa139830651542ca4c288585ecc05d880765fe89a20894", size = 686846, upload-time = "2026-11-23T09:41:40.935Z" },
+ { url = "https://files.pythonhosted.org/packages/b8/ce/a44f8fffb3dcfeac4d5617b00cb3d5347ffaa98d0480475f79d73649b3b4/tree_sitter-0.27.0-cp314-cp314-musllinux_1_2_x86_64.whl", hash = "sha256:a5e6c36b3e80532fc8287fb980f37a5b8458016bb727d070ec3891a50b56c5bf", size = 700969, upload-time = "2026-11-23T09:41:41.882Z" },
+ { url = "https://files.pythonhosted.org/packages/19/64/df1ff23d9481b75e608685fdc0eae9fd77f4b745e226f7f96c5533b091a5/tree_sitter-0.27.0-cp314-cp314-win_amd64.whl", hash = "sha256:9fd5b516aa6a499cc7bb43eb6e69694b41b8a09636c9bf201f9227391a013559", size = 139084, upload-time = "2026-11-23T09:41:43.065Z" },
+ { url = "https://files.pythonhosted.org/packages/82/62/efecd469f11ca58a8ff9b4965bac2b00a7a57b5e38387341153f25466362/tree_sitter-0.27.0-cp314-cp314-win_arm64.whl", hash = "sha256:2ad4b625191f2fa0ed8d3a86614fcd0b25414bee3f7a88e4f419e0e79d96ca16", size = 130016, upload-time = "2026-11-23T09:41:43.853Z" },
+ { url = "https://files.pythonhosted.org/packages/46/df/6db3160d133451a2d00ed0e1b45aeefe2f780699a59da7af017b67368e60/tree_sitter-0.27.0-cp315-cp315-macosx_10_15_x86_64.whl", hash = "sha256:e94888debca5e8d8c5e5b14f622f8e9b2770961f2224627ef84b4f622fe46a8b", size = 157194, upload-time = "2026-11-23T09:41:44.694Z" },
+ { url = "https://files.pythonhosted.org/packages/b5/e4/036a919780b185bd551abb2ee088e85190496fff793fc8d1ed29929e05d1/tree_sitter-0.27.0-cp315-cp315-macosx_11_0_arm64.whl", hash = "sha256:ad52e16a0a66b13b7be2dcd9a14495d89ae02fe1e6ee62e471285a2737b041ac", size = 148259, upload-time = "2026-11-23T09:41:45.487Z" },
+ { url = "https://files.pythonhosted.org/packages/fb/23/b02ec2cc4467b529a4cdb044fd8371caa0fd0b0034880322faa404777c22/tree_sitter-0.27.0-cp315-cp315-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:3632532b1c23877bd25af0d2d17532c02df6aeb3f43d68e4ff6bda82c1411c29", size = 682580, upload-time = "2026-11-23T09:41:46.326Z" },
+ { url = "https://files.pythonhosted.org/packages/8f/32/91722212dbc0c606f396c4a1d038031ec67a0ab9e89014557b525eb0563f/tree_sitter-0.27.0-cp315-cp315-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:3e2e533c5ea05ecf9c453a6760e3de01cd6c0afa36a8c35f0a17abbcdfe5d059", size = 712946, upload-time = "2026-11-23T09:41:47.29Z" },
+ { url = "https://files.pythonhosted.org/packages/79/b3/e471c1f07420e77266416d072af44f87f25546bca6dd7bf83c121807faf8/tree_sitter-0.27.0-cp315-cp315-manylinux_2_31_riscv64.manylinux_2_39_riscv64.whl", hash = "sha256:ec6d8868381b3839e2f11b18c9ef94c0872b2a56edd39f720c63a6ceeb7c4da9", size = 697949, upload-time = "2026-11-23T09:41:48.298Z" },
+ { url = "https://files.pythonhosted.org/packages/f2/2e/90cd719b5475f0bc1f7eb2dc6670415ef1b33af7718932533a868fe353bd/tree_sitter-0.27.0-cp315-cp315-musllinux_1_2_x86_64.whl", hash = "sha256:9fe7faa4d7065f7eb82d69bdc4c9f414fe42ef902be387af9bea9f7e5130821b", size = 705754, upload-time = "2026-11-23T09:41:49.153Z" },
+ { url = "https://files.pythonhosted.org/packages/ab/40/65a4d7831a5183a1f1cc168eb97b99f25661799fe5f7247ed931c1512221/tree_sitter-0.27.0-cp315-cp315-win_amd64.whl", hash = "sha256:c6454681c8a2f64a2f78840d064d4972913c750916d2ed0631ece394859bab01", size = 139087, upload-time = "2026-11-23T09:41:50.06Z" },
+ { url = "https://files.pythonhosted.org/packages/13/10/9c81ea8cdeee802de2faf91d1355947195ee3a8d53228bc03cea067f01c3/tree_sitter-0.27.0-cp315-cp315-win_arm64.whl", hash = "sha256:4fc860a9636fa29ee8bf5777e1c5b6537e6c5147c97ef6cb596f0678aeaeaadc", size = 130019, upload-time = "2026-11-23T09:41:50.847Z" },
+]
+
+[[package]]
+name = "tree-sitter-language-pack"
+version = "1.23.1"
+source = { registry = "https://pypi.org/simple" }
+resolution-markers = [
+ "python_full_version == '3.10.*'",
+]
+dependencies = [
+ { name = "tree-sitter", version = "0.26.1", source = { registry = "https://pypi.org/simple" } },
+]
+sdist = { url = "https://files.pythonhosted.org/packages/78/39/995494c7732d945360a75d5cda5f0428f60c2985e45f391c6e3fe8e29a54/tree_sitter_language_pack-1.23.1.tar.gz", hash = "sha256:ebd76299a70d7387932d35bf6ed388e7822445c363526a0e7cc7f31f14d81bf5", size = 70587, upload-time = "2026-11-02T02:05:59.906Z" }
+wheels = [
+ { url = "https://files.pythonhosted.org/packages/d9/2c/76333d53e86506e7f74a511d29811e4bb532faad4e2989ad622ce45a8754/tree_sitter_language_pack-1.23.1-cp310-abi3-macosx_10_12_x86_64.whl", hash = "sha256:81ea85e3cb1d15164a2ecb64fd15e213ab6366977a424d1f74b096b7f06aef10", size = 2289597, upload-time = "2026-11-02T02:05:50.811Z" },
+ { url = "https://files.pythonhosted.org/packages/a2/3e/63adcac14d4e75f86eb7b5d85e9d2f38e1f1c99144a24a838c296744b039/tree_sitter_language_pack-1.23.1-cp310-abi3-macosx_11_0_arm64.whl", hash = "sha256:cc0e6789e7c759fd29da58176c54bf6869cf0936b7d59724f851b108c8adcf6f", size = 2175161, upload-time = "2026-11-02T02:05:52.812Z" },
+ { url = "https://files.pythonhosted.org/packages/51/b9/e685126af89ab3a3d2b8efdc52e9ebcdfd7e9f9a8c71c0ce93c26f3a35ee/tree_sitter_language_pack-1.23.1-cp310-abi3-manylinux_2_34_aarch64.whl", hash = "sha256:b9597ef3971a4ec842fdf2b51a9fd5210f9c5a38ab35e11bffa3188ddf145411", size = 2334535, upload-time = "2026-11-02T02:05:54.179Z" },
+ { url = "https://files.pythonhosted.org/packages/9c/21/c84919f91a07cfb135469d59b37c93b68970bf279bce71d67a18c85ee9bf/tree_sitter_language_pack-1.23.1-cp310-abi3-manylinux_2_34_x86_64.whl", hash = "sha256:0091c27b7f9d625d1181582abafaae8a0f3d0aa9d39c2d2048016ffbb0e17790", size = 2452822, upload-time = "2026-11-02T02:05:55.554Z" },
+ { url = "https://files.pythonhosted.org/packages/3b/4d/3f3bfc6fcc4c00ef285e8925b354c13970f36dad55a96f192a088978155c/tree_sitter_language_pack-1.23.1-cp310-abi3-win_amd64.whl", hash = "sha256:3dc50ff0ba575480a437a575947c3e3247dd79b1511811d2741a0790f6dd9fe9", size = 2239402, upload-time = "2026-11-02T02:05:57.274Z" },
+ { url = "https://files.pythonhosted.org/packages/01/18/a03f664a0c2a12ced2c72451bfb83958c00951643d60f4046d51ede126d1/tree_sitter_language_pack-1.23.1-cp310-abi3-win_arm64.whl", hash = "sha256:292a63023da2a90541ac63d24fe13bbe5790abf49b450376a2534ac574245d29", size = 2145049, upload-time = "2026-11-02T02:05:58.771Z" },
+]
+
+[[package]]
+name = "tree-sitter-language-pack"
+version = "1.29.0"
+source = { registry = "https://pypi.org/simple" }
+resolution-markers = [
+ "python_full_version >= '3.11'",
+]
+dependencies = [
+ { name = "tree-sitter", version = "0.27.0", source = { registry = "https://pypi.org/simple" } },
+]
+sdist = { url = "https://files.pythonhosted.org/packages/1f/25/4b4db46dc1cbb27cecdc6af7827cf664e9b6b3a91be31a9d63177c8c2e57/tree_sitter_language_pack-1.29.0.tar.gz", hash = "sha256:c8ee2e1f87080cc43e0fe173c5e9096f054d838c744a9650a3e37da1785ff820", size = 70776, upload-time = "2026-12-03T16:24:42.644Z" }
+wheels = [
+ { url = "https://files.pythonhosted.org/packages/bc/a7/d482e1e0b6239f5ad08bf77c99dcf8c49b143211f75f8f135897e2cc9fed/tree_sitter_language_pack-1.29.0-cp311-abi3-macosx_15_0_arm64.whl", hash = "sha256:8af65bc25c689ab679b6d1ddaec518f8b6a3ea8a77b24b0d4b53e6f96d76f63f", size = 2311685, upload-time = "2026-12-03T16:24:33.278Z" },
+ { url = "https://files.pythonhosted.org/packages/6b/d8/54a47c1b242ae73cea4af7cb8194a9c0f3fc4706bb71cf61fa6ca762cf38/tree_sitter_language_pack-1.29.0-cp311-abi3-macosx_15_0_x86_64.whl", hash = "sha256:532401dae5095f6fdb74b3665983f184577136c9f9a1cfacf1fdafaa115b3066", size = 2412018, upload-time = "2026-12-03T16:24:34.782Z" },
+ { url = "https://files.pythonhosted.org/packages/1c/1f/f36b6d52d2710807c2c607d857bcbc91ec11599ec2091246e376a2fdeb75/tree_sitter_language_pack-1.29.0-cp311-abi3-manylinux_2_34_aarch64.whl", hash = "sha256:bd81702a79d292076a8a696e13bc82155f11cb893b7db51c9e072f0b9625eaf8", size = 2471190, upload-time = "2026-12-03T16:24:36.47Z" },
+ { url = "https://files.pythonhosted.org/packages/e4/ad/d773c6534c93437a73c757927b81bb3e113a05ecdbcbbcb01660b64866c5/tree_sitter_language_pack-1.29.0-cp311-abi3-manylinux_2_34_x86_64.whl", hash = "sha256:8860cba2de08869732bbf9fbd34193969d9970841b2cfd7f99e649c3ef02d32d", size = 2573912, upload-time = "2026-12-03T16:24:37.966Z" },
+ { url = "https://files.pythonhosted.org/packages/d0/18/326c7057a10863965ce17c1ee80c978544a54decdb209fe114fbe27e641b/tree_sitter_language_pack-1.29.0-cp311-abi3-win_amd64.whl", hash = "sha256:bb8e061effa46f57dc4dc47b910ace81c730e592d5e7efcea4b53cde923ca0aa", size = 2365407, upload-time = "2026-12-03T16:24:39.742Z" },
+ { url = "https://files.pythonhosted.org/packages/6d/dd/99af8bcc802b8adad7d2ff2ce5b56c05c539a8f754fbee69e6f93b350365/tree_sitter_language_pack-1.29.0-cp311-abi3-win_arm64.whl", hash = "sha256:d157c9004096ff16e5e5537c9b48580d97eecfddac0c6c0a84525f8cfbefdac1", size = 2284938, upload-time = "2026-12-03T16:24:41.168Z" },
+]
+
[[package]]
name = "typing-extensions"
version = "4.15.0"